Colvis with DataTables "Uncaught TypeError: Cannot read property 'style' of undefined"
Colvis with DataTables "Uncaught TypeError: Cannot read property 'style' of undefined"
NoMan2000
Posts: 7Questions: 3Answers: 0
The error occurs when using Colvis to Show/hide a column. The error that gets triggered:
Uncaught TypeError: Cannot read property 'style' of undefined. It gets thrown on:
for ( i=0 ; i<visibleColumns.length ; i++ ) {
column = columns[ visibleColumns[i] ];
headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
_fnStringToCss( column.sWidthOrig ) : '';
}
The fix is trivial:
for ( i=0 ; i<visibleColumns.length ; i++ ) {
column = columns[ visibleColumns[i] ];
if (!headerCells[i]) {
continue;
}
headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
fnStringToCss( column.sWidthOrig ) : '';
}
But it brings up questions about how the visible columns are being calculated.
This discussion has been closed.
Answers
Can you link to the page showing the issue so I can debug it please?
Allan
Yes same issue here.... error is thrown when dataTables.responsive.js tries to hide columns..
ColVis and Responsive are not compatible. They can't be used together at the moment.
However, it shouldn't be throwing an error. Could you try the 1.10.8-dev nightly version of DataTables please?
Allan
We're doing a bunch of testing on our development server, probably tomorrow I can give you a login and test the 1.10.8 version.
Zach and I probably have the same error for the same reason, I'm using Colvis with Responsive.