Centering text in column ...

Centering text in column ...

rob morningrob morning Posts: 30Questions: 7Answers: 1

In a datatable I have ..

  $('#despatchEntryDetails').dataTable({
        "columnDefs": [
          {"className": "dt-center", "targets": "_all"}
        ],

Expected this to centre text in all the columns but it don't seem to be working .. Any ideas ?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I would expect that to work as well, and indeed it does here: http://live.datatables.net/piqukeje/1/edit .

    My guess is you are using an old version of DataTables - although without a test case I can't be sure.

    Allan

  • rob morningrob morning Posts: 30Questions: 7Answers: 1

    I'm using 1.10.7 .. ?

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I would need a link to the page to understand why it isn't working in that case. As you can see from my example it can and should work.

    Allan

  • rob morningrob morning Posts: 30Questions: 7Answers: 1

    It's an intranet application .. maybe I can post all the script (it's quite small) but i'm not sure it would help .. I also use Bootstrap ..

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    I also use Bootstrap ..

    Key point. I didn't know that before (which is why the forum rules ask for test cases so I can get all the information required :-) ).

    The dt-center class is part of the DataTables stylesheet - not Bootstrap, nor the DataTables / Bootstrap integration. I might change that in future, but for the moment you would just add:

    th.dt-center, td.dt-center { text-align: center; }
    

    to your CSS.

    Allan

  • rob morningrob morning Posts: 30Questions: 7Answers: 1

    Thanks .. my bad .. works now

This discussion has been closed.