How do I make the number "1000" showed as "1,000"?
How do I make the number "1000" showed as "1,000"?
guoguoguo
Posts: 3Questions: 2Answers: 0
I searched thru the forum and found posts about number format. It seems it's by default showed as 1,000 rather than 1000. But it's not. The HTML is very simple:
<td>3201800</td>
Do I have to use external JavaScript functions to pre-modify it?
This discussion has been closed.
Answers
This example shows how to use the number rendering function.
{ data: "salary", render: $.fn.dataTable.render.number( ',', '.', 0, '$') }
https://editor.datatables.net/examples/simple/simple.html
-fixed some odd copy/paste artifacts
@ThomD
Thanks, but the solution requires a fixed count of the column. In my tables they are not fixed. Some table has 5 columns and some has 7. Is there kind of something any 'global settings'?
You can still use that approach, but use
columnDefs
to target one or more columns either by column index or by class name. You do need to tell DataTables which columns you want to format though - it won't just apply a global formatter to all numbers.Allan