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

Is there a GridViewDateTimeColumn for WPF

5 Answers 188 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 15 Aug 2014, 04:13 PM
I want to put a GridViewDateTimeColumn into my WPF RadGridView but GridViewDateTimeColumn doesn't seem to exist in Telerik.Windows.Controls (all the other GridView column controls seem to be there, just not this one). Am I missing something?
Dave

5 Answers, 1 is accepted

Sort by
0
Accepted
Boris
Telerik team
answered on 18 Aug 2014, 03:50 PM
Hello Dave,

You are correct - there is no such column as GridViewDateTimeColumn. However, you can create one by following the Create Custom DateTimePicker Column tutorial. In addition, you will need to create a class that derives from GridViewBoundColumnBase and override the CreateCellEditElement() method. For example you can do something like the following:

public class DateTimePickerColumn : GridViewBoundColumnBase
    {
        public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
        {
            this.BindingTarget = DateTimePicker.SelectedDateProperty;
            var picker = new DateTimePicker();
            picker.SetBinding(this.BindingTarget,this.CreateValueBinding());
            return picker;
        }
 
        private Binding CreateValueBinding()
        {
            var valueBinding = new Binding();
            valueBinding.Mode = BindingMode.TwoWay;
            valueBinding.NotifyOnValidationError = true;
            valueBinding.ValidatesOnExceptions = true;
            valueBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
            valueBinding.Path = newPropertyPath(this.DataMemberBinding.Path.Path);
            return valueBinding;
        }
    }

I attached a sample project that demonstrated the suggested approach. 

Please examine the attached project and let us know how it goes.

Regards,
Boris Penev
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Ravi
Top achievements
Rank 1
answered on 25 Aug 2014, 09:27 AM
Hi Boris,

I'm using same solution and it works fine except for one thing.

The DateTimePicker in the editing row doesn't allow the keyboard-input to work seamlessly as compared to the same when you don't place the DateTimePicker as a column.

When I (1) edit by keyboard and change the date or time part, and (2) press Enter key, it considers the edit.
But when I (1) edit by keyboard and change the date or time part, and (2) press Tab key, or click outside the DateTimePicker, the editing is lost and I'm back with the old values.

I don't want the users to always press Enter key to keep their edits from keyboard.

Please suggest a workaround for this.
0
Dimitrina
Telerik team
answered on 28 Aug 2014, 08:01 AM
Hello,

I tested the specified steps using the keyboard keys in the demo solution my colleague attached. I was not able to reproduce an issue with committing the edit in case I finish it with the Tab key or clicking on another row/cell. You can check the video I captured to illustrate my test.

Do you reproduce it in the attached demo project?

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Dave
Top achievements
Rank 1
answered on 28 Aug 2014, 08:42 AM
Thanks Boris. I used your sample project to create the control which seems to work fine.
However I must say I am puzzled that Telerik have not provided this control for WPF. Every GridView Column control that is provided for Windows Forms seems to be provided for WPF except for this one. Is there some reason for this omission?
Dave
0
Dimitrina
Telerik team
answered on 28 Aug 2014, 01:17 PM
Hi Dave,

Thank you for sharing your feedback.
The reason why we have not added such a column is that there was not enough demand. You can always create your custom column to serve the exact scenario you would like.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Dave
Top achievements
Rank 1
Answers by
Boris
Telerik team
Ravi
Top achievements
Rank 1
Dimitrina
Telerik team
Dave
Top achievements
Rank 1
Share this question
or