Comma as decimal separator and thousands separator
Comma as decimal separator and thousands separator
These two must be related as I think I can't get dataTables to recognize numbers with comma as decimal separator as numbers instead of strings...
I've read that numeric-comma.js is deprecated.
According to formatted numbers this is also deprecated.
The values in cells I'm retrieving are originated in a php call to MariaDB, where each numeric value is subject to this transformation: replace( round($field,2), '.', ',' ).
The values are retrieved with two decimal cases and comma as a the decimal separator, as intended. But, when I sort it using the up and down arrows at each column, the column is sorted as a string, not as a numeric value.
I inserted the code shown at language.decimal but the only thing it changed was the thousands separator of the text at the footer of the table: "Showing 10 to 25 of 13'464 entries".
This question has an accepted answers - jump to answer
Answers
Can you link to a test case showing the issue please? This example shows the use of the
language.decimal
option - which is also documented in the manual.If that isn't working for you, a test case would be great so I can debug it.
Allan
Hi Allan,
I've found the issue that was preventing the correct handling of columns with comma as the decimal separator.
In aoColumnDefs I had this line:
{ "sType": "numeric", "sClass": "right", "aTargets": [ 5,6,7,8 ] },
After I removed it, sorting is working great.
Thank you for your answer and for this excellent product!
Ah! Yes, that would force the "simple" numeric method to be used, and wouldn't be stripping out the formatted data. The new types in 1.10 are much more capable than the old ones :-)
Allan