Allow comma separated numbers using the 'Ignore text' plugin.
Allow comma separated numbers using the 'Ignore text' plugin.
Hi,
I recently found the 'Ignore text plugin' which has proved very useful.
http://www.datatables.net/forums/discussion/22343/new-sorting-plugin-sort-by-any-number-ignore-text.
I've found however that the sorting doesn't work when you have comma separated numbers inter mixed with numbers that don't have commas. Is there a way of modifying the regex so that it will also ignore commas also?
I've put a fiddle together as an example of the issue...
http://jsfiddle.net/Adam84/nz69gbm4/3/
Any help is really appreciated!
This question has an accepted answers - jump to answer
Answers
Does this jsfiddle accurately represent your data? Because the data in there would not require that plugin. When you remove
type: 'sort-numbers-ignore-text',
and rerun it, everything works fine.Either way, I edited the jsfiddle to make it work. The regex had to be changed, and parseFloat does not work with commas so you have to also strip them for ordering purposes which isn't a big deal since it does not impact the cell value. Take a look here.
This works really well, thanks for your help!