Filtering Datetime column

4 posts, 0 answers
  1. Tyler
    Tyler avatar
    13 posts
    Member since:
    Jun 2012

    Posted 25 Nov 2014 Link to this post

    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?
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Nov 2014 Link to this post

    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.

     
  3. Tyler
    Tyler avatar
    13 posts
    Member since:
    Jun 2012

    Posted 25 Nov 2014 in reply to Dimitrina Link to this post

    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?
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Nov 2014 Link to this post

    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.

     
Back to Top