Sorting after search
Sorting after search
PastorBones
Posts: 1Questions: 0Answers: 0
I'm using the formatted-num plugin for sorting numbers with a thousands separator. The plugin code is:
jQuery.fn.dataTableExt.oSort['formatted-num-pre'] = function(a) {
a = (a === "-") ? 0 : a.replace( /[^\d\-\,]/g, "" );
return parseFloat( a );
};
jQuery.fn.dataTableExt.oSort['formatted-num-asc'] = function(a,b) {
return a - b;
};
jQuery.fn.dataTableExt.oSort['formatted-num-desc'] = function(a,b) {
return b - a;
};
var tsTable = $('#ts_info').dataTable( {
"oLanguage": {
"sSearch": "Search all columns:"
}
, "aoColumns": [
null
, { "sType": "formatted-num" }
, null
]
});
Text
Number
Text
plain text
1,125
plain text
plain text 2
125
plain text 2
This works as expected until I filter the table through search, then it's as if the plugin isn't called. Am I doing something wrong?
jQuery.fn.dataTableExt.oSort['formatted-num-pre'] = function(a) {
a = (a === "-") ? 0 : a.replace( /[^\d\-\,]/g, "" );
return parseFloat( a );
};
jQuery.fn.dataTableExt.oSort['formatted-num-asc'] = function(a,b) {
return a - b;
};
jQuery.fn.dataTableExt.oSort['formatted-num-desc'] = function(a,b) {
return b - a;
};
var tsTable = $('#ts_info').dataTable( {
"oLanguage": {
"sSearch": "Search all columns:"
}
, "aoColumns": [
null
, { "sType": "formatted-num" }
, null
]
});
Text
Number
Text
plain text
1,125
plain text
plain text 2
125
plain text 2
This works as expected until I filter the table through search, then it's as if the plugin isn't called. Am I doing something wrong?
This discussion has been closed.