Sorting functions problem
Sorting functions problem
chandrashekar
Posts: 8Questions: 0Answers: 0
Hi Allan,
i have colom in datatbale where data is combination of sting and number eg. ' VIN001252 ' i need to sort only on number so i added Anti-"VIN" plugin to Datatable,
[code]
jQuery.fn.dataTableExt.oSort['anti-vin-asc'] = function(a,b) {
var x = a.toLowerCase().replace(/^VIN /i, "");
var y = b.toLowerCase().replace(/^VIN/i, "");
x = parseInt( x );
y = parseInt( y );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['anti-vin-desc'] = function(a,b) {
var x = a.toLowerCase().replace(/^VIN /i, "");
var y = b.toLowerCase().replace(/^VIN /i, "");
x = parseInt( x );
y = parseInt( y );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
[/code]
This above code was working perfectly with dataTables-1.7 version.
but need to fnDestroy function so upgraded to dataTables-1.7.3 version. now this sorting is not happening. i am also not getting any script error.
could you please give me suggestion to fix it
regards
chandrashekar
i have colom in datatbale where data is combination of sting and number eg. ' VIN001252 ' i need to sort only on number so i added Anti-"VIN" plugin to Datatable,
[code]
jQuery.fn.dataTableExt.oSort['anti-vin-asc'] = function(a,b) {
var x = a.toLowerCase().replace(/^VIN /i, "");
var y = b.toLowerCase().replace(/^VIN/i, "");
x = parseInt( x );
y = parseInt( y );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['anti-vin-desc'] = function(a,b) {
var x = a.toLowerCase().replace(/^VIN /i, "");
var y = b.toLowerCase().replace(/^VIN /i, "");
x = parseInt( x );
y = parseInt( y );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
[/code]
This above code was working perfectly with dataTables-1.7 version.
but need to fnDestroy function so upgraded to dataTables-1.7.3 version. now this sorting is not happening. i am also not getting any script error.
could you please give me suggestion to fix it
regards
chandrashekar
This discussion has been closed.