Decimal comma separator not working
Decimal comma separator not working
laneasis
Posts: 2Questions: 1Answers: 0
Hi, I have something like these data in one column:
http://live.datatables.net/pasukibu/1/edit
When I try to search this "24,1" i think I would see 2 records. I don't see nothing. When i serahc "24.1" everything works great. In Polish we often use a numeric keyboard to wrte numbers and between Enter and 0 is our separator which is ",". What I do wrong?
Thanks for reply and have a nice day
This discussion has been closed.
Answers
This:
does not do what you would expect it to do.
See the docs here:
https://datatables.net/reference/option/language
All it does is to make data tables use a decimal comma in its user interface. The user interface is NOT the content of your data table. It is the header, footer, control elements etc. of the data table - where the incidence of decimal points or commas etc is, well, not very frequent
So if you render your values using decimal points you cannot search for values with decimal commas.
@allan: this should be changed in the docs! Nobody including myself understood this initially ...
Same here
What you can do is user or browser language specific rendering. I support two languages German(Germany) and English(UK).
If the selected language is German I render decimal points as commas and thousand separators as periods.
It the selected language is English decimal points remain unchanged and the same applies to the thousand separators which are commas.
You can do the user specific number rendering server side (which I do mostly) or client side using this for example:
https://datatables.net/manual/data/renderers#Built-in-helpers
@rf1234 Thanks for reply. Sorry for that, but maybe I understanding something bad.
See this:
http://live.datatables.net/qazekoro/1/edit
These number is not especially number , is like some code for products and it looks like: 26.20.1, 26.20.2, 45.40.1 etc. I have a sqlite database for data in this table and youtr tip works well, but I cant's see äll"number - when i delete third parametr I see only integer, but when I add third parameter I see zeros after that.
I hink it's too heavy for me Maybe some source data modification and change '.'for '.'in database, but this will be another work for me, when I want to update database for new records.
Thanks for reply and sorry for my English but I'm still learn it.
You can use any kind of renderer if you like. I use many custom renderers and I use them client and server side (mostly server side: Easier in my opinion - if you use Editor.)
Don't know how you save this in your database. Let's assume you save it like this as a string: 26.20.1
For Polish you would simply replace the periods with commas server side in your getFormatter. And in your setFormatter you would replace all commas with periods. That's all!
With Editor this would look like this (PHP, but you can also use .NET and others):
Nie martw się! Nawet nie musisz się tego uczyć. Wpisałem ten tekst na deepl.com i jak widzicie mój polski jest płynny! Zaufaj mi, nie rozumiem ani jednego słowa po polsku. Ale kogo to obchodzi?
Roland