Sorting using data-order on epoch time is wrong on most browsers
Sorting using data-order on epoch time is wrong on most browsers
adie
Posts: 2Questions: 1Answers: 0
I have a weird situation that has never happened before, the order is incorrect on the latest Chrome installed on windows machines and mobiles browsers but it's correctly ordered on Chrome on MacOS Sierra. I use data-order with epoch time to order the column descendingly. Any idea what might cause this issue? PS: I cleared every and any cache, no help
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Happy to take a look if you post a link to a test case. The epoch is just an integer, so there really shouldn't be any issue with the sorting element. More likely it isn't detecting that it should be sorting on that data point for whatever reason.
Allan
Thanks for the reply Allan. I kinda figured out the issue. Seems like it was sorting by the date string instead of the epoch time data-order attribute. The order results were different on multiple browsers because of the system locale settings.
If you are using
columns.render
as a function, what you return from it (when thetype
issort
) is what DataTables will use for the ordering data. In this case it is an HTML string - hence the issue.You want to return only
row.lastModified
under those conditions.See the orthogonal data section for more details.
Regards,
Allan