Formatted Number Search and Localization

Formatted Number Search and Localization

HeberdaHeberda Posts: 3Questions: 1Answers: 0

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?

https://jsfiddle.net/heberda/9cqfbn7v/

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    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

  • HeberdaHeberda Posts: 3Questions: 1Answers: 0

    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/

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    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

  • HeberdaHeberda Posts: 3Questions: 1Answers: 0
    edited March 2018

    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...

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    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

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Unrelated note, I see the Nuget package is a version out anyway...

    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

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    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

This discussion has been closed.