This is the content of my datatable:
05.06.2020 10:46
14.08.2020 11:18
17.09.2020 01:24
17.09.2020 04:42
20.08.2020 01:47
20.08.2020 04:37
22.09.2020 02:05
23.09.2020 13:52
28.04.2020 02:46
28.04.2020 12:00
The sorting is not working correctly, as I am expecting the colums start with the newest date.
This is my approach:
var table = $('.table').DataTable({
"data":{{ data|raw }},
"order": [[ 0, "asc" ]],
....
'createdCell': function init(cell, cellData, rowData, rowIndex, colIndex) {
var unixTimestamp = moment(cellData, 'DD.MM.YYYY HH:MM').unix();
$(cell).html(cellData);
$(cell).attr('data-order', unixTimestamp);
}
But still the sorting is wrong.
I tried this solution How can I sort my DataTables row by date? but it did not work for me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…