api.columns.adjust().draw() doesn't work on hide/show column (when two rows in header)
api.columns.adjust().draw() doesn't work on hide/show column (when two rows in header)
sameeralikhan
Posts: 17Questions: 1Answers: 2
On initialization of DataTable - the column header (with two row) is aligned and width is set properly.
Though - when i try to show/hide a column - the column doesn't adjust. The new unhidden column is weirdly added to the table.
I tried calling "api.columns.adjust().draw()" or "api.columns.adjust().draw(false)" - the columns are not adjusted.
Please note, the above scenario works fine - when we have single column. The problem is with two columns.
This discussion has been closed.
Answers
Please note, the above scenario works fine - when we have single row in a header. The problem is with two rows in a header.
I have found a solution for my problem. The change is required at function _fnGetUniqueThs()
Initialize the variable 'j' together with 'i' - this way it will give all the column from the multiple row at header.
@Allan: Can you check, if this is okay to be updated at plugin level. Might be useful for others who work with complex header and dynamic show/hide of a column.
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Could you post a link to a test page that shows the issue please? I don't quite understand why that change would resolve the issue (I'm slightly concerned it might introduce new issues since
j
is not being reset for each loop).Allan
It's a long code - will spend sometime and prepare that for you. hopefully next week.