How to calculate widths of initially hidden datatable
How to calculate widths of initially hidden datatable

Hello,
This is interesting.
I have a page that shows a tab control with 2 tabs.
The first tab shows some html elements, and the second tab, shows a datatable.
Since the first tab is the default one, second tab is originally hidden, causing the datatable to be initially hidden as well.
In this scenario, DataTable plugin is not able to automatically calculate widths of cells, causing the cells in the header to appear with 0px width.
I am sure that this problem occurs because the DataTable is hidden when it is created, so, can you advice me how can I solve it? maybe I could call some datatable method to recalculate widths when the second tab is shown.
Regards
Jaime
Answers
Hi @jstuardo ,
You should just be able to call
columns.adjust()
when the table becomes visible.If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Thanks colin... I have used "table.columns.adjust().draw();" when the tab becomes visible and it worked. The only detail is that the table appears with a header with wrong widths at first. After one second, the header resizes to accomodate to the rest of the table.