Custom ordering does not seem to be getting called
Custom ordering does not seem to be getting called
dhosek
Posts: 1Questions: 1Answers: 0
I want to be able to reverse the normal ordering of numeric columns with data tables (in part so that when a user clicks on a column heading the default ordering will be high to low). I've done the following:
$(document).ready( function () {
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"rev-pre": function(a) {
return parseInt(a);
},
"rev-asc": function(a,b) {
console.log(a + "\t" + b);
return ((a>b) ? -1 : ((a<b) ? 1 : 0));
},
"rev-desc": function(a,b) {
console.log("rev: " + a + "\t" + b);
return ((a<b) ? -1 : ((a>b) ? 1 : 0));
}
});
$('#rankings').DataTable({
"paging" : false,
"ordering" : true,
"columns" : [null,
{ "type" : "rev"},
{ "type" : "rev"},
{ "type" : "rev"},
{ "type" : "rev"}
],
"order" : [[1, "asc"]]
});
} );
which I thought would work but what I'm finding is that rev-asc/rev-desc are never called (rev-pre, is). Obviously I'm doing something ridiculously wrong here, but I've been unable to figure it out on my own. Any ideas? I'm using 1.10.8 from the CDN
This discussion has been closed.