Sorting a column with german numbers
Sorting a column with german numbers
Hello there,
I have a question about the possibilities to configure the language options for DataTables to ensure a correct sorting of a number column.
I have the following current situation:
1. I have a database which sends back json data to fill the DataTables. This works perfectly.
2. I have configured some number columns in the different DataTables to show numbers in german format with ',' as decimal and '.' as thousands seperator.
The problem now is the sorting of the column. This doesn't work correctly with the german formatted numbers.
I found the solution to add every DataTable following language option:
language: {
decimal: ',',
thousands: '.',
},
This works brilliant and the sorting is down correct.
My question is:
Because I have the defaults configured with $.extend(true, $.fn.dataTable.defaults, { ... }
I want to know if I can set the language options above in these defaults to prevent adding this option every DataTable in my project.
I tried
$.extend(true, $.fn.dataTable.defaults, {
...
language: {
decimal: ',',
thousands: '.',
},
}
but this doesn't work.
Can anyone help me please?
This question has an accepted answers - jump to answer
Answers
Hi @StefanKSK ,
That's a bug, I'm afraid. See this thread here: https://datatables.net/forums/discussion/48223/formatted-number-search-and-localization
It's been fixed, but not yet released - it'll go out in the release after 1.10.16.
In the meantime, if you just add it per table as you are doing, then that should be fine.
Cheers,
Colin
Thank you @colin !
Then I have to do it as i'm doing it already and edit it after the release after 1.10.16 will be published.