Change globally the alignment of cells based on sType
Change globally the alignment of cells based on sType
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
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
This discussion has been closed.
Replies
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
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.
Allan