|
Title: Datagrid Datetime Column Sort [Solved] Post by: Darrel on October 30, 2018, 01:56:03 PM Hello Team,
Basically I wanted to try out sorting on the datagrid column on a date field. The following url that I referred for doing this custom sorting is https://www.jeasyui.com/tutorial/datagrid/datagrid14.php (https://www.jeasyui.com/tutorial/datagrid/datagrid14.php) I had to tweak it a little for dd/mm/yyyy format. But when I introduced the timestamp into the date field, that's when the results started getting weird. The same can be checked in the following fiddle: http://jsfiddle.net/c9so6p3b/ (http://jsfiddle.net/c9so6p3b/) You can change the sorting for the date field and check the results. The output isn't as expected, notice the timestamp part. Please could you help me out. One thing I have in mind is to separate out the time stamp before doing the comparison but then I got stuck on when I need to add it back :( Also just another thought, how would this work in case the date string is in dd/Mon/yyyy format.... Regards, Darrel Title: Re: Datagrid Datetime Column Sort Post by: stworthy on October 30, 2018, 05:58:42 PM Try to define the 'sorter' function as:
Code: sorter:function(date1,date2){Title: Re: Datagrid Datetime Column Sort Post by: Darrel on October 31, 2018, 10:23:17 PM Hello stworthy,
Thanks a lot for your reply. It works as expected. The below code is my modified version which handles the date in dd/Mon/yyyy format as well. Code: var month_names = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]; Thanks & Regards, Darrel. |