This is a migrated thread and some comments may be shown as answers.

Editing Time in a Grid

4 Answers 186 Views
TimePicker
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 18 Mar 2010, 11:31 PM
Hi:

I want to edit a time (from a bound datetime column) in a RadGridView.

I've defined the grid column as follows:

                <radGridView:GridViewDataColumn Header="End Time" 
                        DataMemberBinding="{Binding EndTime, Mode=TwoWay}" DataFormatString="{}{0:hh:mm tt}">  
                    <radGridView:GridViewDataColumn.CellTemplate> 
                        <DataTemplate> 
                            <TextBlock Text="{Binding EndTime}" /> 
                        </DataTemplate> 
                    </radGridView:GridViewDataColumn.CellTemplate> 
                    <radGridView:GridViewDataColumn.CellEditTemplate> 
                        <DataTemplate> 
                            <radInput:RadTimePicker  
                                 SelectedTime="{Binding EndTime, Mode=TwoWay}" /> 
                        </DataTemplate> 
                    </radGridView:GridViewDataColumn.CellEditTemplate> 
                </radGridView:GridViewDataColumn> 
 

I have two problems:
1. The time displays in the TextBlock as mm/dd/yy hh:mm tt.  How can I format the TextBlock to just show the time?  BTW, the following does not work.  It leaves the time blank.  (THe VS2010 syntax coloring has the zero black, the hh brown, the mm blue and the tt red.)

          <TextBlock Text="{Binding EndTime, StringFormat='{}{0:hh:mm tt}'}" /> 
 


2. When I double-click the cell to edit it, the time in the timepicker is blank rather than showing the underlying time which is being edited.  Shouldn't SelectedTime make it show the same time as I saw in the TextBlock?

I'm using SL4 beta.

4 Answers, 1 is accepted

Sort by
0
Surya
Top achievements
Rank 1
answered on 20 Mar 2010, 05:33 AM
Hi,

I have the same issue. I am using VS 2010 RC with SL4 RC. I have defined the grid column as follows.

<telerikGridView:GridViewDataColumn Header="Start Time"  
    DataMemberBinding="{Binding StartTime, Mode=TwoWay}" 
    DataFormatString="{}{0:t}"
    <telerikGridView:GridViewDataColumn.CellEditTemplate> 
        <DataTemplate> 
            <telerikInput:RadTimePicker Loaded="Editor_Loaded" 
                SelectedTime="{Binding StartTime, Mode=TwoWay}" /> 
        </DataTemplate> 
    </telerikGridView:GridViewDataColumn.CellEditTemplate> 
</telerikGridView:GridViewDataColumn> 
 

Please advice.
0
Kaloyan
Telerik team
answered on 24 Mar 2010, 09:43 AM
Hi Surya,

There are some ways to overcome this issue. You can build a ValueConverter that will transform the date to the desire value.  Also you can try to specified the FormatString in the TextBlock binding expression. You should know that the SelectedTime property of the RadTimePicker is of TimeSpan type, not a DateTime object. Let us know if this solutions are not helping you.

Regards,
Kaloyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Terry
Top achievements
Rank 1
answered on 24 Mar 2010, 07:51 PM
I've experimented.  If you are retrieving a SQL Time Column from SQL Server, the type is TimeSpan and the TimePicker selected value initializes correctly.  It successfully initializes to {}{0:hh:mm tt} when you enter edit mode.  But then the problem is, when you're not in edit mode, the TextBlock formatting doesn't understand {}{0:hh:mm tt} and leaves the column blank.  If you remove the StringFormat, the time displays in 24-hour format with seconds.

Unfortunately, this is not something Telerik can fix.  Microsoft formatting for the TextBlock doesn't fully understand the TimeSpan type.

So maybe a converter is the only solution.
0
Kaloyan
Telerik team
answered on 30 Mar 2010, 08:50 AM
Hi Terry,

It seems that this is an appropriate way to achieve this.

Sincerely yours,
Kaloyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TimePicker
Asked by
Terry
Top achievements
Rank 1
Answers by
Surya
Top achievements
Rank 1
Kaloyan
Telerik team
Terry
Top achievements
Rank 1
Share this question
or