How to sort date field in ascending order using sort feature of Kendo-React?

2 Answers 1419 Views
Grid Sortable
Sachin
Top achievements
Rank 1
Iron
Iron
Sachin asked on 31 Oct 2022, 04:52 PM | edited on 31 Oct 2022, 04:53 PM

Hello,

I am trying to sort the date with sort feature inside the grid. But looks like it's not sorting for me based on the time also it's taking as a string.

If you let me how to perform sort on date column then that would be great!

I have added the screenshot and code snippet for the reference


const generateDate = () => {
  const currDate = new Date();
  const formatDateUS = currDate.toLocaleDateString("en-US");
  console.log(formatDateUS);
  return formatDateUS;
};


2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 02 Nov 2022, 01:49 PM

Hello Sachin,

Thank you for contacting us.

In order for the Grid and the data operations to handle the dates correctly, the data for that field must be JavaScript Date object. You can refer to the following example and the orderDate to see the structure of the data and how the column is configured:

Hope this helps.

 

Regards,
Konstantin Dikov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Sachin
Top achievements
Rank 1
Iron
Iron
answered on 07 Nov 2022, 08:17 PM
Thank a lot, I got it!
Tags
Grid Sortable
Asked by
Sachin
Top achievements
Rank 1
Iron
Iron
Answers by
Konstantin Dikov
Telerik team
Sachin
Top achievements
Rank 1
Iron
Iron
Share this question
or