formatting on "sAjaxSource": "server_processing.php",

formatting on "sAjaxSource": "server_processing.php",

diogenesdiogenes Posts: 1Questions: 0Answers: 0
edited September 2012 in DataTables 1.9
I need to format the numbers on my tables in many ways - example adding commas and rounding the decimal places.

using the code i saw that you posted gives me a lot of different output:

45,647,6.4
13,159,.99

Also what about output options for dates from the yyyy-mm-dd SQL?

you have done some great work and I sincerely appreciate you pointing me in the right direction!!! Cheers.

$('#example').dataTable( {
"aoColumnDefs": [
{
"aTargets": [ 0 ],
"bUseRendered": false,
"fnRender": function ( o ) {
return o.oSettings.fnFormatNumber( parseFloat( o.aData[ o.iDataColumn ] ) );
}
}
]
} );

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Can you not use a similar mRender approach (which I would suggest using over fnRender btw - fnRender will be removed in DataTables v1.10)? Or alternatively perhaps you could format the date/time using the SQL engine's formatting options in the query?

    Allan
This discussion has been closed.