Numbers and Currency not being detected
Numbers and Currency not being detected
eoinriggs
Posts: 4Questions: 1Answers: 0
I have some number and currency columns in my HTML table.
I can not get DataTables to identify as a number and right-aling the column and standardize the decimal places.
For example I have '1.1' showing left aligned, rather than $1.10 right aligned.
Thanks
This discussion has been closed.
Answers
Can you link to the page showing the issue please so I can help to debug it.
Allan
H Allan
I have put a link up with a couple of rows of data. I want all the number columns to display as numbers, right aligned with 2 decimals.
http://live.datatables.net/munoveni/1
Thanks
DataTables has a number of built in classes in its stylesheet which you can use to align column text.
To get your numbers formatted as you want, use the number formatter.
Allan
Hi Allan
Thanks for the message, much appreciated.
I tried adding the number formatter, but I cannot get it working.
Could you show me an example of how to use it?
Can you build a test case showing what you've tried and someone can help fix it?
Kevin
Thanks kthrongren.
I have updated my example adding the number formatter, but it does not work. I am clearly missing something obvious.
live.datatables.net/fegohote/1/
Thanks
Good, thanks. I've updated your test case:
http://live.datatables.net/qahoyusu/1/edit
The number formatter example Allan linked to is just a snippet of a full config using
columns.data
. Since you are not using this option thencolumnDefs
needs to be used to define the target column (5) and the renderer.This also needs to be placed inside the Datatables function. Notice the code is within a new set of
{}
.Hope this helps.
Kevin
Thanks Kevin, that works great.