Sorting a column with german numbers

Sorting a column with german numbers

StefanKSKStefanKSK Posts: 4Questions: 1Answers: 0

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? :smile:

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.