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

Clicking on kendo grid header, date sorting is not showing up properly

1 Answer 115 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hamed
Top achievements
Rank 1
Hamed asked on 13 Nov 2018, 01:03 PM
The issue is when we are clicking on kendo grid header, date sorting is not showing up properly.

In response the date is coming as string, but we are converting to date format in controller while displaying in grid, but still sorting is not working. The sorted data is only showing according to day wise not considering the complete date.

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 15 Nov 2018, 10:10 AM
Hello Fazil,

The Grid data needs to contain actual JavaScript Date objects (as opposed to strings) so that the built-in formatting, sorting, filtering and editing functionalities can work as expected:

https://www.telerik.com/kendo-angular-ui/components/grid/data-binding/

When the Grid data contains strings, and strings are sorted lexicographically (the default JavaScript behavior), "03 Oct" will come before "04 Oct" because the character "4" comes after the character "3".

Check out the following example that involves various data operations, the data contains actual dates, and sorting and filtering are working as expected:

https://www.telerik.com/kendo-angular-ui/components/grid/filtering/#toc-filter-row

If the dates are coming serialized from a remote server, the data needs to be mapped such that real Date instances are created from them, before binding the Grid.

I hope this helps.

Regards,
Dimiter Topalov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
General Discussions
Asked by
Hamed
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or