How to use Hidden title numeric sorting for thousands separator
How to use Hidden title numeric sorting for thousands separator
Hi there, im using dataTables with "Hidden title numeric sorting" plugin because my table rows look like this:
1,100.30
8,000.10
120.50
using "," as thousand separators. But im getting the rows sorted like:
1,100.30
120.50
8,000.10
What i've added is this as javascript:
[code]
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"title-numeric-pre": function ( a ) {
var x = a.match(/title="*(-?[0-9\.]+)/)[1];
return parseFloat( x );
},
"title-numeric-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"title-numeric-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
oTable = $('#reprtable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<""f>t<"F"lp>',
"aoColumns": [
null,
null,
{ "sType": "title-numeric" },
null
]
});
[/code]
and my html is:
1
2
1,100.30
4
Can someone help me please?
1,100.30
8,000.10
120.50
using "," as thousand separators. But im getting the rows sorted like:
1,100.30
120.50
8,000.10
What i've added is this as javascript:
[code]
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"title-numeric-pre": function ( a ) {
var x = a.match(/title="*(-?[0-9\.]+)/)[1];
return parseFloat( x );
},
"title-numeric-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"title-numeric-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
} );
oTable = $('#reprtable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<""f>t<"F"lp>',
"aoColumns": [
null,
null,
{ "sType": "title-numeric" },
null
]
});
[/code]
and my html is:
1
2
1,100.30
4
Can someone help me please?
This discussion has been closed.
Replies