className dt-center no longer honored for number columns in DataTables 2
className dt-center no longer honored for number columns in DataTables 2
https://live.datatables.net/kuhuxavi/1/
Debugger code (debug.datatables.net): NA
Error messages shown: no error messages
Description of problem: I am in the process of moving to Datatables 2, and I am noticing that with DataTables 2 number columns are always right aligned even if I specify className dt-center as part of the column definition. Using the column type "string" is not a possibility since column type affects how a column is sorted. How can I get the previous behavior of DataTables back where dt-center was honored even for number columns?
This question has an accepted answers - jump to answer
Answers
The issue is that DataTables 2 applies a class automatically based on the data type (which it never used to). The default for numbers is
dt-right
, which is taking priority over your application ofdt-center
simply on account of the order of the classes in the string. I will look and see if I can change that, but in the mean time there are two options:dt-body-center
which has a higher specificity: https://live.datatables.net/kuhuxavi/3/editAllan
Ah, that's perfect! Either of these approaches will work for me. Thank you for your help!
Beate