Using ScrollX/Y Prevents Hiding/Showing Columns
Using ScrollX/Y Prevents Hiding/Showing Columns
If the table has scrollX
/scrollY
defined, it prevents the columns from being hidden then shown again.
The bin below shows the error. When first displayed, the last two columns are hidden using column().visible()
, then, five seconds later, they are shown again. The error occurs when the visible method is called. The visibleColumns array is being increased before the headerCells array is, which is causing the error.
http://jsbin.com/winonatupi/1/edit
In _fnAdjustColumnSizing, _fnCalculateColumnWidths is called before _fnScrollDraw. The issue is that _fnScrollDraw adds back the column to the scroll bodies hidden thead element, but _fnCalculateColumnWidths is expecting that column to already be there, which it isn't.
Simply moving _fnScrollDraw above _fnCalculateColumnWidths seems to fix the issue. Not entirely sure if _fnScrollDraw should be split into two parts, one to be called before the calculation, and one after.
See https://github.com/DataTables/DataTables/commit/20daefef556b56209985104c14ed3a1b2e5ede61
Thanks
Ken
Answers
Hi Ken,
Unfortunately this is a bug in the 1.10.7 release. It has already been fixed in the nightly (1.10.8-dev) which you can grab from the downloads page.
Updated version of your example with the latest version.
Allan
Thank you.