Custom classes for specific instances of the table
Custom classes for specific instances of the table
Hello, Allan.
Thank you for the great DataTables project!
One question that I have but did not find an obvious solution or explanation in the forums is this - I need to set custom classes (particularly, add a custom class to .dataTables_wrapper) to the generated table. Requirements:
- the custom class is needed only for some of the datatables on the page therefore I don't know how I could override $.fn.dataTableExt.oJUIClasses without affecting other tables (yes, I use jQueryUI styling in all of them),
- the class needs to be applied *before* the table is rendered, particularly before the column widths are calculated because they depend on the custom classes.
I do not want to fire an extra fnAdjustColumnSizing just because I add another class - the table is already quite heavy to render, one extra render request would make it even slower.
I have seen (but can't find where) an idea to swap the dataTableExt object when creating a table and it sounds very hacky to me but I'll go with it before I get any other ideas.
Is there any reason classnames can not be given as initialisation parameters?
Thank you for any feedback or ideas!
Linas
Thank you for the great DataTables project!
One question that I have but did not find an obvious solution or explanation in the forums is this - I need to set custom classes (particularly, add a custom class to .dataTables_wrapper) to the generated table. Requirements:
- the custom class is needed only for some of the datatables on the page therefore I don't know how I could override $.fn.dataTableExt.oJUIClasses without affecting other tables (yes, I use jQueryUI styling in all of them),
- the class needs to be applied *before* the table is rendered, particularly before the column widths are calculated because they depend on the custom classes.
I do not want to fire an extra fnAdjustColumnSizing just because I add another class - the table is already quite heavy to render, one extra render request would make it even slower.
I have seen (but can't find where) an idea to swap the dataTableExt object when creating a table and it sounds very hacky to me but I'll go with it before I get any other ideas.
Is there any reason classnames can not be given as initialisation parameters?
Thank you for any feedback or ideas!
Linas
This discussion has been closed.
Replies
> Is there any reason classnames can not be given as initialisation parameters?
Yes two reasons: 1. Generally this is done for all tables on the page and 2. to keep the number of initialisation options manageable and sane :-)
Allan
Yes but only:
- after the initialisation is complete (after .dataTable({}) call) or
- for the elements that are there before the initialisation (table, thead, tbody, ...)
Thank you!