columnControl: Numeric search does not understand specified number format
columnControl: Numeric search does not understand specified number format
We are facing an issue with the columnControl search functionality for numeric values (gt, lt, etc.).
- We display numeric values with ',' as decimal instead of '.' and a suffix
- We achive this by passing
DataTable.render.number('.', ',', 1, '', ' %')
Expected behaviour:
Searching gt with ',' works. For example 2,6 % is displayed and should be searchable with gt 2,5.
Observed behaviour:
Searching with ',' does not work. Only searches using '.' work.
I assume this does not work because the parameter is directly parsed to a number in the search without regards to the format.
We also set the language.decimal option, just in case, but still no success.
Is there a way to match the search's decimal character with the number format's?
Answers
Hi,
Thanks for your post and apologies for the delayed reply. Are you able to link to a test case showing the issue so I can take a look at the problem please? I need to know the full configuration of the table (e.g. server-side processing mode is a key one).
Allan
Thank you for your reply. I do not directly have an option to link a test case, but it's a plain table using columControl with a column with the format function, no server-side processing. A similar behaviour can be observed in the official examples (https://datatables.net/extensions/columncontrol/examples/search/manualType.html). The Salary column has the format $162,700 but a search for eq 162,700 yields no result.
My guess is, that the columnControl search does not know about the render options, thus handling it "wrong".
I looked at the columnControl source (https://github.com/DataTables/ColumnControl/blob/5cca29f935c264e449ce49a3cb35efcb5d5c2854/js/content/searchNumber.ts#L146) and it looks like that may be the root of our issue? 2,6 maybe is not recognized as 'numeric' and then is subjected to the regex formatting?
I see that yes. I hadn't expected people to type in a formatted number for the search to be honest, although I guess someone could copy and paste a value.
Perhaps a fix would be to make the input numeric based?
Allan
I guess that's more an issue with the decimal and less the formatted 1000 point. For example a German user would expect 2,3 to work and would not necessarily guess 2.3.
Our "workaround" was to not use a german format (eg. 100.111,32€) where filtering is necessary. And hope the users do not notice this discrepancy.
Not sure what a correct fix would look like.