Align cells, override individual columns for built in datatypes

Align cells, override individual columns for built in datatypes

Wooly65Wooly65 Posts: 67Questions: 19Answers: 1
edited May 3 in Free community support

In the discussion https://datatables.net/forums/discussion/comment/228325/#Comment_228325 you mentioned:
You could assign other classes if you prefer. It looks like dt-type-date will take preference over dt-left regardless of order in the class list, I suspect due to the ordering in the CSS. I'll look at that as well.

The user mentioned:
The problem is, the custom class is added before the automatic class, so its styles are overwritten, including the for me important text-align.

I don't want to override all dt-type-numeric columns in my datatable from being right aligned, but I was hoping I could add the className: 'dt-left' to those columns identified as dt-type-numeric that I want to override. Were you able to review the CSS for precedence.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,029Questions: 1Answers: 10,168 Site admin
    Answer ✓

    I haven't found a way to do that yet, however, it can be done with a little CSS:

    table tr td.dt-type-numeric.dt-left {
      text-align: left;
    }
    

    https://live.datatables.net/cecodewu/1/edit (Age column).

    Allan

  • Wooly65Wooly65 Posts: 67Questions: 19Answers: 1

    Thanks for the info, I also had to add CSS for the header

    table thead th.dt-left.dt-type-numeric,
    table tr td.dt-type-numeric.dt-left {
        text-align: left;
    }
    
Sign In or Register to comment.