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

DatePicker in GRidView

7 Answers 351 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Siingh
Top achievements
Rank 2
Siingh asked on 02 Jun 2011, 09:54 AM
Hi Telerik
can you help in getting DatePicker working in GridView, in WPF
i have tried this link gridview-how-to-create-date-time-picker-column and Custom Column also none of above work.

then i tried using simple example with Resources and i can get DatePicker in Grid column but i cant see bounded data in it.

it always shows me "Enter Date" but no selected date is visible i have binded Gridview using code behind with DataTable()


Help me please

7 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 03 Jun 2011, 12:41 PM
Hi Siingh,

I found your same query here  and in several other  forum posts as well .
To aviod duplication , I will keep further cmmunication in a single place.
You may find my further answers ( and a sample project ) there .

Regards,
Pavel Pavlov
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
Saykor
Top achievements
Rank 2
answered on 09 Oct 2014, 04:06 PM
Hi,
It will be good to update your example at http://www.telerik.com/help/wpf/gridview-how-to-create-date-time-picker-column.html

It break on the styles because you assume we will use RadClockStyle.

And the second problem is with binding property. It is set to Established. Of course I can change to my needs for example StartDate but what is suppose for another property let say EndDate? I need to build another DateTimePickerColumnVersion2?

The official example not work as universal reusable solution. It is for specific case and will be good if is updated to work as is suppose.

Regards,


0
Boris
Telerik team
answered on 14 Oct 2014, 11:39 AM
Hi Saykor,

In general the Create Custom DateTimePicker Column article is meant to guide you through the common task of creating a custom column in RadGridView and not to be an universal solution. However, if it does not suit your needs, you can use it as a template that can be modified or rewritten for your specific case. In addition the RadClockStyle is only used to set a custom Header to RadTimePicker. A possible reason for it to break is because you are using full binaries instead of NoXAML. To use the style with full binaries you can remove it's BasedOn property. In addition if you do not need the custom header at all, you can just remove it.

I hope this helps.

Regards,
Boris Penev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Saykor
Top achievements
Rank 2
answered on 14 Oct 2014, 12:51 PM
Hi Boris,
Again I will ask for a universal solution provided from a Telerik team because nobody will make it more good from Telerik itself.
High-Quality Programming Code is reusable and it is suppose to be in the official Telerik's articles.

Other question is after so much years of existing on Telerik radgridview for WPF why so much other cases on different Columns is not implemented in the control and we need to do them manually.

But for now how to build Reusable Custom Column will be good.

Regards,
0
Accepted
Boris
Telerik team
answered on 16 Oct 2014, 12:38 PM
Hello Saykor,

In order to try and make the code more reusable I changed the binding of the SelectedValue property of the RadDatePicker and RadTimePicker controls, located in the CustomDateTimePicker.xaml file. Now they are bound to the SelectedDate dependency property of the CustomDateTimePicker class. Thus avoiding the hard codded binding to the Established property of the Club class.

<UserControl x:Class="CustomDateTimePickerColumn_WPF.CustomDateTimePicker"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:CustomDateTimePickerColumn_WPF"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.Resources>
            <Style x:Key="RadClockStyle" TargetType="telerik:RadClock">
                <Setter Property="Header" Value="TimePicker" />
            </Style>
        </Grid.Resources>
        <telerik:RadDatePicker x:Name="Calendar"
                               SelectedValue="{Binding SelectedDate,
                                                       RelativeSource={RelativeSource AncestorType={x:Type local:CustomDateTimePicker}}}"
                               SelectionChanged="OnCalendarSelectionChanged" />
        <telerik:RadTimePicker x:Name="TimePicker"
                               Grid.Column="1"
                               ClockStyle="{StaticResource RadClockStyle}"
                               SelectedValue="{Binding SelectedDate,
                                                       RelativeSource={RelativeSource AncestorType={x:Type local:CustomDateTimePicker}}}"
                               SelectionChanged="OnTimePickerSelectionChanged" />
    </Grid>
</UserControl>

I attached a sample project demonstrating the suggested approach. Could you please examine it and let us know if that was what you had in mind?


Regards,
Boris Penev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Saykor
Top achievements
Rank 2
answered on 20 Oct 2014, 05:17 PM
Thank you
This is exactly what I need. Unfortunate I can't select it as a answer because i not start this thread.
0
Boris
Telerik team
answered on 21 Oct 2014, 07:17 AM
Hi Saykor,

I am glad that my solution was able to fulfill your requirement. In addition I marked as answer my previous reply.

Regards,
Boris Penev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Siingh
Top achievements
Rank 2
Answers by
Pavel Pavlov
Telerik team
Saykor
Top achievements
Rank 2
Boris
Telerik team
Share this question
or