Link to home
Start Free TrialLog in
Avatar of maddisoncr

asked on

Datatables jQuery Format Problem

I am using the datatables plug in and i want to show numerical data with 2 decimal places.

I am using similar php scripts that the author uses and as such, i don't to format the data at that stage.. i want to format the data client side

I have found a datatables article : but it uses depreciated methods

I also want to produce my own calculated columns

Avatar of maddisoncr


Avatar of Rainer Jeschor
depending on your data / html source, the following option should work:
            "aoColumnDefs": [ 
                "mRender": function ( data, type, row ) {

                    return parseFloat(data).toFixed(2);
                "aTargets": [ 6 ]

Open in new window

Just verify the column index - from the attached PDF it looks like column 7 (hence index 6).


Thank you so much, i really appreciate it

How would i go about looking at calculated columns ?
thanks again for that, it's working great

in terms of adding commas.. i presume i would still use the plug in as before ?
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks so much, i'll test that this afternoon :-)
Thanks again.. Brilliant
Great help
                               "mRender": function (data, type, row) {
                                   return parseFloat('currentBalance').toFixed(2);
The above is not working for me.  What do I need to do?  The data type for 'currentBalance' is decimal.