sort on dates not working properly after upgrade to 1.10.5
sort on dates not working properly after upgrade to 1.10.5
apfz
Posts: 2Questions: 0Answers: 0
after updating from datatables 1.10.4 to 1.10.5 sorting on dates is not working properly anymore. For example descended sorting shows 31 Jan 2015 11:46 on top and 01 Jan 2015 14:11 at the bottom. A date like 08 Feb 2015 04:48 can be found somewhere in the middle. Looks like it is sorting on the first number only. Is this a bug?
This discussion has been closed.
Replies
Can you link to a test case showing the issue please.
It is worth noting that without a plug-in the only reliable data format for sorting is ISO8601 since DataTables uses the built in
Date.parse
in Jvascript which varies a huge amount by browser.Allan
I have the exact same problem.
Here is how I reproduce it.
I have an empty table with regular thead, containing a column named "Date". I initialize DataTables:
I load rows with a standard jQuery request, then:
Cells containing dates have a data-sort attribute, containing ISO date. myrows is simply an array of jQuery tr objects.
The table display is fine, I can order on other columns but containing dates.
DataTables will detect data attributes only on initialisation. See this GitHub discussion on the topic, particularly my last comment for how to resolve it.
Allan
Ok. Thank you for answer.
However, I just tried using the documented ajax method, where the server sends back an array of objects. Each object looks like this:
The column is initialized with the render attribute:
And it still doesn't sort dates correctly. Am I missing something else ?
With that code the type detection will be running on the
display
property. You will want to add:to your object as well.
Allan
Ok, now it works. Excellent, thank you very much !