Add dollar sign and two decimal places to an entire column

Add dollar sign and two decimal places to an entire column

goopcatgoopcat Posts: 4Questions: 2Answers: 0

Been struggling for a few days to get this to work right. Other discussions have deprecated contents that won't work any more. I cant even get the fnFormatNumber example to work.

Let me know what you need of my code to give any help.

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    edited September 2014

    DataTables has a built in number renderer as of 1.10. The feature isn't fully developed which is why there is little documentation about it, but the Editor examples use it. For example:

    { data: "salary", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) }
    

    will render the salary number with a , as the thousands separator, . as the decimal place, 0 decimal places and $ as the prefix. This is the prototype for the number renderer.

    I plan to expand on that feature and document it more completely in future with plug-ins being available to provide different renderer types. Just a question of getting the time to do so!

    Allan

This discussion has been closed.