12 Answers, 1 is accepted
Hello Bob,
It depends on if you want to show the time part or not. If not then you can use schema.parse to strip the time part from the object, so you can filter by date only like this:
http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.parse
Or you can implement serverFiltering and handle the filtering on the server based on your specific requirements.
Regards,Kiril Nikolov
Telerik
Basically, we want to stay with Telerik, but many of the features in the Telerik WebForms controls aren't ported over to Kendo. So users lose features or we come up with hacky work-arounds in many instances.
columns.Bound(m => m.DateCreatedDate).Template(@<
text
></
text
>).Title("Date Created").ClientTemplate("#=kendo.toString(DateCreatedDateTime,'M/d/yyyy hh:mm tt')#").Width(170).Format("{0:M/d/yyyy}");
Basically, we want to stay with Telerik, but many of the features in the Telerik WebForms controls aren't ported over to Kendo. So users lose features or we come up with hacky work-arounds in many instances.
columns.Bound(m => m.DateCreatedDate).Template(@<
text
></
text
>).Title("Date Created").ClientTemplate("#=kendo.toString(DateCreatedDateTime,'M/d/yyyy hh:mm tt')#").Width(170).Format("{0:M/d/yyyy}");
Hello Bob,
If you want to implement all client operations, you can use template to pass the date with the time porting and filter on a separate field, that is date only. Here is an example:
http://dojo.telerik.com/@Kiril/IDiMU
Regards,Kiril Nikolov
Telerik
Hello Bob,
The implementation is the same with the server widgets, please try to implement it in your project and if you stumble upon any particular issue, please do not hesitate to contact us.
Regards,Kiril Nikolov
Telerik
Hello Bob,
Please note that the standard support services, do not provide on demand coding. As an exception I have prepared an example and you can find it attached here.
Regards,Kiril Nikolov
Telerik
Requirements:
1) Display date and time
2) Sort by date, then time
3) Filter by date only
Hello Bob,
I am afraid that the sorting can only be done by the value that is bound on the column - in your case the value without the time portion. The scenario that you describe in your latest post cannot be achieved with client side operations only.
Regards,Kiril Nikolov
Telerik
Hi, I'm sorry to bring up an old post but I think I've found a solution and want to share and hopefully save others some time. Or if there is a problem with the way I'm doing it please let me know.
I'm defining two fields, one with the time stripped out ("EventDateFilter") and one with the full datetime ("EventDate"). I'm binding to EventDateFilter and then displaying EventDate in the template.
So that's a pretty easy solution for Filtering and Grouping, but still leaves sorting. For that I override the sort manually when it is set to EventDateFilter. This is in the databound event (since there is no sorting event that I know of).
If there is no sort yet I default it to the EventDate so you may or may not want that behavior. I'm tracking the last direction in a "private" variable which is probably a little goofy but seems to be working.
I can only think of two issues:
1. The sort happens twice, no big deal in my case.
2. The sort indicator does not appear in the column header, probably a way to do that manually but I dont care at the moment.
var
grid = $(
"#gridTimeEntry"
).data(
"kendoGrid"
);
//set default sort
if
(grid.dataSource.sort().length == 0) {
grid.dataSource.sort({ field:
"EventDate"
, dir:
"asc"
});
}
else
{
if
(grid.dataSource.sort()[0].field ==
"EventDateFilter"
) {
log.info(
"overriding filter"
);
if
(_sortDirection ==
"asc"
) {
_sortDirection =
"desc"
;
}
else
{
_sortDirection =
"asc"
;
}
grid.dataSource.sort({ field:
"EventDate"
, dir: _sortDirection });
}
}
Hello Kjell,
Thank you for sharing your solution with the community.
Actually starting from the Kendo UI 2016 R3 (2016.3.914) release there is a sort event available in the Kendo UI Grid options. The event is fired when the user is about to modify the current state of sort descriptors of DataSource via the sort UI.
Regards,Boyan Dimitrov
Telerik by Progress