Sorting currency column
Sorting currency column
ripcurlksm
Posts: 10Questions: 4Answers: 0
I am having problems sorting the "Amount" column... its sorting by the first integer instead of the entire value
http://lifescienceintelligence.com/EMT-Deals-Table/
Its sorting like this:
$1,000,000
$100,000,000
$2,000,000
Instead of this:
$1,000,000
$2,000,000
$100,000,000
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You have specified:
Remove that - it isn't needed in DataTables 1.10. DataTables will automatically detect and sort your numeric currency column.*
Edit No it won't because you had string data in the column: "Undisclosed". You would need to create a sorting plug-in that will handle that. The formatted numbers plug-in might work - although it might require a change to add
Undisclosed
to the list of options that it treats as0
.Allan
Thanks for taking a look Allan, how are you at regex to tweak the formatted numbers plugin for "Undisclosed"?
Here is the current page:
http://lifescienceintelligence.com/EMT-Deals-Table/index.html
And here is the 'formatted numbers' plugin code im using:
http://lifescienceintelligence.com/EMT-Deals-Table/extensions/formatted-numbers.js
A regex tweak not needed here - see the bit which has
(a === "-" || a === "")
- just add an extra condition which checks forUndisclosed
there.Allan
Thank you that worked!