Ordering by data-order type = num doesn't work.
Ordering by data-order type = num doesn't work.

Hello everyone,
I have a problem.
In my table the sorting of the table does not work.
The column is configured with orderable = true, type = "num".
The cell gets the attribute data-order with a timestamp
<td name="time" data-order="1593543527" class="sorting_1">31.06.2020</td>
But there is no error during sorting - nothing happens even though the timestamps are different.
Version: DataTables 1.10.22
Thanks and best regards
Florian
This discussion has been closed.
Answers
Please provide a link to your page or a running test case showing the issue so we can see what you have and help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Hello Kevin,
I have now set up a test environment and tried to
There you will find exactly the use case.
To test this call <link removed>
User: datatables
pwd: dt2020
The page in question is opened directly.
Column "Datum" (Date) and "Bewertung" (Rating) are the problem.
Thanks a lot
Thanks for the test case. Thats a lot of code to dig through. I took what I thought was important and built a simple test case replicating your data, the
prepareRow()
function andcolumnDefs
:<link removed>
The problem is replicated. I removed the
"type; "num"
from theDatum
column and the sorting appears to work.Normally you don't need to set the
columns.type
. Datatabes performs automatic type detection and will override what you specify if another type of data is found in the column.Try removing the ``"type; "num"`. If that doesn't help then try to update my simple test case to show the issue.
Kevin
Hello, Kevin,
thank you for your quick answer.
Unfortunately it does not work like this. The date is not sorted correctly.
The 15.07.2020 is always on the 3rd place, but this date must be either at the beginning or at the end.
Therefore I set the timestamp in the cell in data-order="". And set the column as type="num".
But then there seems to be no sorting at all
best regards
Florian
Hello, Kevin,
I have found the solution.
It was due to the configuration of columnDefs. There I also had data="time" etc. in it and therefore my changes to the cell itself had no effect.
Thanks for your efforts!
Is it possible to remove the URL and the access data above in the post?
best regards
Florian
Glad its working now. I removed the links and sent a PM, CCing you, to Colin to remove the test case.
Kevin
thanks :-)