className dt-center no longer honored for number columns in DataTables 2

className dt-center no longer honored for number columns in DataTables 2

LimpEmuLimpEmu Posts: 72Questions: 20Answers: 1

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

  • allanallan Posts: 63,676Questions: 1Answers: 10,497 Site admin
    Answer ✓

    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 of dt-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:

    1. Use dt-body-center which has a higher specificity: https://live.datatables.net/kuhuxavi/3/edit
    2. Set the class that is applied for the numeric data types to be the one you want: https://live.datatables.net/kuhuxavi/4/edit .

    Allan

  • LimpEmuLimpEmu Posts: 72Questions: 20Answers: 1

    Ah, that's perfect! Either of these approaches will work for me. Thank you for your help!
    Beate

Sign In or Register to comment.