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

DateTime Column Filter

9 Answers 1291 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sri
Top achievements
Rank 1
sri asked on 08 Oct 2012, 09:40 AM
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.

9 Answers, 1 is accepted

Sort by
0
Steven
Top achievements
Rank 1
answered on 04 Jan 2013, 03:15 AM
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.
0
Rosen
Telerik team
answered on 09 Jan 2013, 07:27 AM
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!
0
Palani
Top achievements
Rank 1
answered on 14 Apr 2013, 01:29 PM
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>
0
SEAN
Top achievements
Rank 1
answered on 26 Apr 2014, 06:13 PM
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.
0
Rosen
Telerik team
answered on 28 Apr 2014, 07:11 AM
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.

 
0
Andreas
Top achievements
Rank 1
answered on 30 Apr 2015, 07:05 AM

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...

0
Rosen
Telerik team
answered on 04 May 2015, 08:17 AM
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.

 
0
SEAN
Top achievements
Rank 1
answered on 07 May 2015, 12:09 AM
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.
0
Rosen
Telerik team
answered on 07 May 2015, 03:23 PM

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.

 
Tags
Grid
Asked by
sri
Top achievements
Rank 1
Answers by
Steven
Top achievements
Rank 1
Rosen
Telerik team
Palani
Top achievements
Rank 1
SEAN
Top achievements
Rank 1
Andreas
Top achievements
Rank 1
Share this question
or