datatables version – 2.0.1
Without using serverside we can use data-order attribute for custom sort. I want to use it in serverside too, as I have a column where it contains mixed data sets like int, float, string. The sorting is happening by take the column as a string. So I’m getting 75 at first then getting 100.
Example : [0, 100, 75, 100, NA] is sorted desc as [75, 100, 100, 0, NA]. Sorry I cannot link a test case please don’t ask for it.
`drawCallback: function(settings){
var api = this.api();
var data = api.rows({ page: ‘current’ }).data();
// Loop through rows and add custom sort data
api.rows({ page: 'current' }).every(function(rowIdx) {
var node = this.node();
var sortOrder = $(node).find('td:first-child').data('order');
data[rowIdx].sortOrder = sortOrder;
});
// Sort data based on the custom sortOrder value
data.sort(function(a, b) {
return a.sortOrder - b.sortOrder;
});
// Redraw the table with the sorted data
api.clear();
api.rows.add(data);
api.draw();
}`
I have tried this but it’s not helping