Change globally the alignment of cells based on sType

Change globally the alignment of cells based on sType

vijayidkdvijayidkd Posts: 1Questions: 0Answers: 0
edited February 2013 in General
Hi Datatable experts,

Is there a global way to align the cells in the table based on their type. By default, all cells are aligned to the left when dataTable is applied. I need to align numbers to the right, date to the center and the rest to the left.

On my search, i found that using $.fn.datatableExt, there are ways to custom define the sorting, filtering and other features of a column based on it's sType, but couldn't get clearly how to change the alignment.

I prefer a solution to be applied globally instead of applying during every datatable initialization.

Regards
Vijay.K

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    > Is there a global way to align the cells in the table based on their type

    No, but you can easily use sClass to add a class to the cells and align them. Having said that, there isn't currently a method of DataTables automatically detecting and adding a class like that. A bit of an oversight I think - surprised it hasn't come up before actually. I will have a think about the best way to add something like that without impacting performance on all tables.

    Allan
  • gihadgihad Posts: 1Questions: 0Answers: 0
    edited April 2013
    Hi Allan,

    I'm a long time user of DataTables, kudos for this amazing plugin. Are there any updates on this question? This seems like a very common and widely desired feature, I'm also surprised it hasn't come up before. The need to do this often comes up in the various reporting projects I worked on.

    Thanks,
    Gihad.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    edited April 2013
    No changes - the same as before applies - just use sClass to set a class on the cells and apply the CSS as needed to that class.

    Allan
This discussion has been closed.