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

Filtering Datetime column

3 Answers 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tyler
Top achievements
Rank 1
Tyler asked on 25 Nov 2014, 02:18 PM
I have a grid that has several Date Time columns. The value in these columns is dependent towards the time and not so much the date. When I go into the filter and enter a date and a time the filter does not accept this value and clears the field when I tab out or click somewhere else. However if I only enter a date and no time it will accept that filter. How do I get the filter to accept the time value as well?

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Nov 2014, 02:55 PM
Hi,

Have you eventually set the DataMemberBinding or FilterMemberPath to be the Date value only? You can also check our online documentation for a further reference.

Regards,
Dimitrina
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
Tyler
Top achievements
Rank 1
answered on 25 Nov 2014, 08:43 PM
My datamember binding is bound to a datetime value. So if I understand correctly this should not be the problem. My situation is the exact opposite of the documentation you provided. If I enter a date value then it filters correctly and accepts the date in the filter field. This makes all of my data disappear due to the fact that my data has a time stamp on it as well. However, if I enter a date and a time then the field clears out and doesn't filter. My ultimate goal is to simply show the time of the datetime field and not the date. I dont actually care about the date. I want the user to see only the Time value and to also be able to filter by only the time. Is this accomplished easily?
0
Dimitrina
Telerik team
answered on 26 Nov 2014, 08:11 AM
Hello,

If you wish to filter on the time only, then you should specify FilterMemberPath to be the Time representation of the original DateTime value. If you do the same for the DataMemberBinding, then you will also see only the time displayed. One way to do so would be to directly specify the DateTime.TimeOfDay property. 
For example:
<telerik:GridViewDataColumn DataMemberBinding="{Binding Established.TimeOfDay}" Header="Est." />

As another approach you can expose a new property of your business object to represent the time and use it instead.

Regards,
Dimitrina
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
Tyler
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Tyler
Top achievements
Rank 1
Share this question
or