Ignore empty cells when sorting while server side processing is enabled
Ignore empty cells when sorting while server side processing is enabled
rushenn
Posts: 1Questions: 1Answers: 0
Before I move to server side processing, I was using a custom sorting method to ignore empty cells when sorting.
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
'dateNonStandard-asc': function (a, b) {
var x = Date.parse(a);
var y = Date.parse(b);
if (x == y) { return 0; }
if (isNaN(x) || x < y) { return 1; }
if (isNaN(y) || x > y) { return -1; }
},
'dateNonStandard-desc': function (a, b) {
var x = Date.parse(a);
var y = Date.parse(b);
if (x == y) { return 0; }
if (isNaN(y) || x < y) { return -1; }
if (isNaN(x) || x > y) { return 1; }
}
});
Since this is a client method, look like it's no longer works as I'm using server side processing.
Complete Code
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
'dateNonStandard-asc': function (a, b) {
var x = Date.parse(a);
var y = Date.parse(b);
if (x == y) { return 0; }
if (isNaN(x) || x < y) { return 1; }
if (isNaN(y) || x > y) { return -1; }
},
'dateNonStandard-desc': function (a, b) {
var x = Date.parse(a);
var y = Date.parse(b);
if (x == y) { return 0; }
if (isNaN(y) || x < y) { return -1; }
if (isNaN(x) || x > y) { return 1; }
}
});
$('#minio-data').DataTable({
"processing": true,
"serverSide": true,
"ajax": "/data-src",
columnDefs: [
{ type: 'dateNonStandard', targets: [-1, -2] }
]
});
How can get the same client side sorting behavior when server side processing is enabled?
Thank you.
This discussion has been closed.