Format Numbers
Format Numbers
dobulet302
Posts: 38Questions: 0Answers: 0
I have a table with decimal places and comma's and I am not using php to format my numbers as when I do it causes a sorting issue. Is there a plugin that will format all my numbers? Example 1000 will be 1,000 and 1233.323522 will be 1,233.323522.
This discussion has been closed.
Replies
Here's one: http://javascript.about.com/library/blnumfmt.htm
Allan
[code]
$('#reports_table').dataTable( {
"sDom": '<"H"lTfr>t<"F"ip>',
"bPaginate": false,
"bJQueryUI": true,
"fnFormatNumber": function (iIn) {
if ( iIn < 1000 ) {
return iIn;
} else {
var s=(iIn+""), a=s.split(""), out="", iLen=s.length;
for ( var i=0 ; i
} );
[/code]
sorry javascript isn't really my strong language, and I thank you for your assistance I will be making a donation.
So for example:
[code]
$('#example').dataTable( {
"aoColumnDefs": [
{
"aTargets": [ 0 ],
"bUseRendered": false,
"fnRender": function ( o ) {
return o.oSettings.fnFormatNumber( parseFloat( o.aData[ o.iDataColumn ] ) );
}
}
]
} );
[/code]
Basically what this does is to target the first column (aTargets:[0]) with a rendering function which will take the data for that column and format it using the internal DataTables function...
How does that go for you?
Allan