Formatted Number Search and Localization
Formatted Number Search and Localization
Hi guys, I have been banging my head on a keyboard trying to work out what is going on and I've managed to create a very simple jsfiddle which outlines my issue.
I have a column with thousand separated and possibly decimal separated numbers, e.g. 1,234 | 1,345 | 4.34.
I require this data to be sort-able. Out of the box DataTables is doing a good job of this, until... I decide to override the Decimal and Thousand defaults. The reason I am doing this is that the data could use a full stop for thousand separation and a comma for decimal indication.
Please see the following jsfiddle and could someone explain why the second table doesn't sort?
This question has an accepted answers - jump to answer
Answers
Hi Heberda,
That stumped me too - you've found a bug! The problem is that the language over-ride properties are being ignored in part of the code, which then breaks the sorting. This will be fixed shortly, but in the meantime, the workaround isn't too onerous...
If you slip the language defaults into each table's initialisation instead, like this example, then that'll work as expected.
Sorry for the inconvenience, but a good spot!
Cheers,
Colin
Thanks for getting back to me, glad I could help find a bug.
To add further to my confusion I have another scenario along the same lines... I've used your workaround which is what I think my application is doing at some point. The odd thing is, once I've used your workaround once, this change propagates to all instances?? is it somehow altering the defaults? You can see here in my latest fiddle.
https://jsfiddle.net/heberda/9cqfbn7v/27/
Yeah, I noticed that too. It's because the sorting functions are shared between all tables, so if one has created the functions needed, the others can also use it.
C
Ok, thanks. The latter isn't particularly an issue for us seen as the decimal separator is setup on page load and never changed without a page refresh.
I hate to be that guy but do we know if this is likely to be fixed within one to two weeks? It makes a difference to whether I implement the work around.
Unrelated note, I see the Nuget package is a version out anyway...
I don't know what the schedule will be, but I've linked this post to the case, so I'll write back and let you know when it's fixed/available.
C
The NuGet package isn't maintained by us - its packages up by a third party. We don't currently publish NuGet packages I'm afraid.
Allan
I've just committed the fix for this and it will be in the next release of DataTables.
Thanks for letting us know about it!
Allan