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

Handling date field from DataTable in RadGridView with RadDatePicker

3 Answers 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ferenc Gál
Top achievements
Rank 1
Ferenc Gál asked on 28 Apr 2010, 09:45 AM
Hi,

I would like to ask for help, I tried to find a solution in emos and forum threads, but I failed.
I have a DataTable binded to a RadGridView. One of the columns in the binded DataTable is date and I want to display/edit it in a RadDatePicker. Somehow I didn't manage to bind it correctly. I binded the date field to the GridViewDataColumn with DataMemberBinding, but I can not pass it to the template. I can not even pass it to a TextBlock template. However I managed to display and edit with a non-templated GridViewDataColumn. But my goal is to display and edit the date values with RadDatePicker. I guess the main difference is with your provided demo thet here I want to bind a datatable and I must use DataMemberBinding for its field, but I can not use it inside a CellTemplate. I would be greateful if you could ge me a tip or sample code how to resolve this problem.  Here is a sample:

 

 

 

<Window.Resources>

 

 

 

 

    <bl:TimeBand x:Key="timeBands"/>

 

</Window.Resources>

 

...

 

 

 

<telerik:RadGridView Name="grTimeBand" AutoGenerateColumns="False" ActionOnLostFocus="CommitEdit" ShowGroupPanel="False" ItemsSource="{Binding Source={StaticResource timeBands}, Path=TimeBandTable, debug:PresentationTraceSources.TraceLevel=High}">

 

 

 

 

    <telerik:RadGridView.Columns>

 

 

 

 

        <telerik:GridViewComboBoxColumn Header="InclAllSpecDays" Width="100" ItemsSourceBinding="{Binding Source={StaticResource booleanValues}, Path=BooleanValueList}" DataMemberBinding="{Binding INCLUSIVE_ALL_SPECIAL_DAYS}" />

 

 

 

 

        <telerik:GridViewDataColumn DataMemberBinding="{Binding START_TIME}">

 

 

 

 

            <telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

                <DataTemplate>

 

 

 

 

                    <TextBlock Text="{Binding START_TIME, debug:PresentationTraceSources.TraceLevel=High}" /> ?????

 

 

 

 

                </DataTemplate>

 

 

 

 

            </telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

            <telerik:GridViewDataColumn.CellEditTemplate>

 

 

 

 

                <DataTemplate>

 

 

 

 

                    <telerikInput:RadDatePicker SelectedDate="{Binding START_TIME, Mode=TwoWay}" />

 

 

 

 

                </DataTemplate>

 

 

 

 

            </telerik:GridViewDataColumn.CellEditTemplate>

 

 

 

 

        </telerik:GridViewDataColumn>

 

 

 

 

        <telerik:GridViewDataColumn Header="EndTime" Width="100" DataMemberBinding="{Binding END_TIME}"/>
        ...
                        
    </telerik:RadGridView.Columns>

 

 

 

 

 

 

 

 

</telerik:RadGridView>

 

3 Answers, 1 is accepted

Sort by
0
Ferenc Gál
Top achievements
Rank 1
answered on 28 Apr 2010, 09:46 AM
I am sorry for the code design, when I wrote it did not look like this.
0
Accepted
Vlad
Telerik team
answered on 28 Apr 2010, 10:00 AM
Hello,

Please try Binding with square brackets ([ ]) instead:

<telerik:GridViewDataColumn  DataMemberBinding="{Binding  [START_TIME]}">
            <telerik:GridViewDataColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding [START_TIME]}" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
            <telerik:GridViewDataColumn.CellEditTemplate>
                <DataTemplate>
                    <telerikInput:RadDatePicker SelectedDate="{Binding [START_TIME], Mode=TwoWay}" />
                </DataTemplate>
            </telerik:GridViewDataColumn.CellEditTemplate>
        </telerik:GridViewDataColumn>

Kind regards,
Vlad
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
Ferenc Gál
Top achievements
Rank 1
answered on 28 Apr 2010, 10:59 AM
Hi,

Thanks for the rapid and great answer. It is rather simple, but I would have never figure it out.

Ferenc
Tags
GridView
Asked by
Ferenc Gál
Top achievements
Rank 1
Answers by
Ferenc Gál
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or