DateTime Column Filter

10 posts, 0 answers
  1. sri
    sri avatar
    21 posts
    Member since:
    Jan 2011

    Posted 08 Oct 2012 Link to this post

    In Kendo UI Grid, if you have a dateTime Column then the column filter input has a date picker but no time picker. Due to this if you select option IsEqualTo and give a date then you get zero results as the time is set to 00:00:00 in the filter but the columns have some time value.

    eg.

    values in my column are
    08-10-2012 15:08:00
    05-09-2012 15:23:00

    and when u use the filter then the value in the filter is
    08-10-2012 00:00:00

    hence when You give the option of IsEqualTo then you get zero values.
  2. Steven
    Steven avatar
    8 posts
    Member since:
    Sep 2012

    Posted 03 Jan 2013 Link to this post

    Did anyone find a solution for this? I store all my date/times as datetime fields. I need the filter with datepicker to work for matching a date to a datetime field. This must be possible.
  3. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 09 Jan 2013 Link to this post

    Hello Steven,

    Although, this is not possible with the current release, we are working on such improvement which should be included in the next service pack.

    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  4. Palani
    Palani avatar
    5 posts
    Member since:
    Jul 2012

    Posted 14 Apr 2013 Link to this post

    Yes it is possible.
    @(
     Html.Kendo().Grid<Employee>()
     .Name("gd")
     .Filterable(f => f.Extra(false))
    .Columns(x =>
        {
            x.Bound(p => p.ID);
            x.Bound(p => p.Name);
            x.Bound(p => p.Email);
            x.Bound(p => p.DateOfJoining).Format("{0:MM/dd/yyyy hh:mm tt}").Filterable(f => f.UI("DateTimeFilter"));
        })
        .DataSource(d => d.Ajax().Read(a => a.Action("ReadData","Home")))
    )


    <script type="text/javascript">
        function DateTimeFilter(control) {
            $(control).kendoDateTimePicker();
        }
    </script>
  5. SEAN
    SEAN avatar
    36 posts
    Member since:
    Sep 2008

    Posted 26 Apr 2014 in reply to Rosen Link to this post

    Rosen, did this ever get implemented, in the 2014.1.328 release I'm still seeing column filtering on datetime columns return no results when you set the filter to Is Equal To.
  6. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 28 Apr 2014 Link to this post

    Hello SEAN,

    The mentioned improvement is the feature Palani is referring to. You may modify the filter UI element to be a DateTimePicker widget instead of a DatePicker. This way the user will be able to pick the exact date and time. However, if you need to keep the DatePicker, it will be required to strip the time portion of the dates in order filtering to work.

    Regards,
    Rosen
    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.

     
  7. Andreas
    Andreas avatar
    5 posts
    Member since:
    Feb 2013

    Posted 30 Apr 2015 in reply to Rosen Link to this post

    This does not even work in the latest release => 2015.1.408.545

    @Rosen How can the time portion be stripped of a datetime value without converting the datetime to a string? When It is a string then the filtering with "is greater/smaller than" is surely be broken too. 

     This is the job of the telerik dev to strip the time from the source datetime values when the filtering is done.

     I am dissappointed from telerik how such a common feature does not work for years...

  8. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 04 May 2015 Link to this post

    Hello Andreas,

    You do not need to convert the DateTime to String, but instead you should create a new DateTime object which contains only the Date portion of the original date.
    Also another approach to handle this is described in this forum post - which uses a custom model binder to change the filter descriptors.

    Although, it may seems a bit odd the way date filtering is handled, this is due to the fact that there is not way to automatically know if it should match the exact date and time or strip the time portion. Thus, it keeps the time as this is the less destructive of the both and give the developer the option to decide the behavior by providing the correct data.

    Regards,
    Rosen
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  9. SEAN
    SEAN avatar
    36 posts
    Member since:
    Sep 2008

    Posted 06 May 2015 in reply to Rosen Link to this post

    Rosen, that doesn't make any sense. You say there is no way to know if it should match the exact date and time or strip the time portion, but that is not true, if the UI element is a DatePicker then we clearly only want to match the date portion, it makes no sense at all to include the time when the user cannot have possibly entered the time. If the developer wants to filter to specific times (a fringe use case) then make them do the extra work, the way it works now you're making developers do extra work to implement the most common use case.
  10. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 07 May 2015 Link to this post

    Hello Sean,

    Actually, the filtering is done either by the DataSource or on the server-side. Thus, the DataSource(or server method) does not have any knowledge what UI (if such is used at all) is used to create the filter expressions passed to its filter method. As I have mentioned, it is currently not possible to automatically pass this information from the UI to the DataSource, thus it is in the hands of the developer to implement the correct behavior.

    Regards,
    Rosen
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top