You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is your problem ? A description of the problem, not the solution you are proposing.
To make the numbers easier to read, I added some formatting with thousands separators, but this breaks column sorting because the sorting internally uses parseFloat(), which stops parsing at the first comma it encounters
Describe the solution you'd like
The easiest solution would be to strip commas from the string before attempting to parse it as a float. At line 36 of sqlpage.js we could replace
There is a minor drawback, because strings that contain numbers separated by commas (e.g: 15,16,17) will now be parsed and sorted in a different way. But I do not think that anyone is currently sorting strings like those.
Describe alternatives you've considered
I have not considered other alternatives for now. One might argue that my solution is bad since it is locale-dependent, and that is 100% true. But I think it would still be better than current behavior.
A possible flexible solution would be using some kind of markdown, so that the number used for sorting is different from the string used to display it.
The text was updated successfully, but these errors were encountered:
Hi!
One much bigger drawback is that in many languages , is a decimal separator, not a thousands separator. In Europe, Latin America, and large parts of Africa, 1,000 < 100.
The right solution, I believe, would be to let SQLPage do the number formatting on the client side, using native browser APIs. Would you be interested in opening a pull request implementing that?
Hi! I know that in some countries the comma is used as a decimal separator, since I live in such a country myself! :)
However, the current algorithm for sorting is broken for this usecase anyway, since right now if the integer part is the same, the rest of the
number is ignored. So, for example, 0,5 and 0,6 are currently rearranged randomly when sorting.
I will try to hack a solution that formats numbers on client side, if I manage to put something together in a reasonable amount of time I will make a pull request.
What are you building with SQLPage ?
A reporting tool with big numbers in a table!
What is your problem ? A description of the problem, not the solution you are proposing.
To make the numbers easier to read, I added some formatting with thousands separators, but this breaks column sorting because the sorting internally uses
parseFloat()
, which stops parsing at the first comma it encountersDescribe the solution you'd like
The easiest solution would be to strip commas from the string before attempting to parse it as a float. At line 36 of
sqlpage.js
we could replacewith
There is a minor drawback, because strings that contain numbers separated by commas (e.g:
15,16,17
) will now be parsed and sorted in a different way. But I do not think that anyone is currently sorting strings like those.Describe alternatives you've considered
I have not considered other alternatives for now. One might argue that my solution is bad since it is locale-dependent, and that is 100% true. But I think it would still be better than current behavior.
A possible flexible solution would be using some kind of markdown, so that the number used for sorting is different from the string used to display it.
The text was updated successfully, but these errors were encountered: