Colvis with DataTables "Uncaught TypeError: Cannot read property 'style' of undefined"

Colvis with DataTables "Uncaught TypeError: Cannot read property 'style' of undefined"

NoMan2000NoMan2000 Posts: 7Questions: 3Answers: 0
edited August 2015 in Free community support

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.

Answers

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin

    Can you link to the page showing the issue so I can debug it please?

    Allan

  • zachpainter77zachpainter77 Posts: 22Questions: 1Answers: 1

    Yes same issue here.... error is thrown when dataTables.responsive.js tries to hide columns..

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin

    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

  • NoMan2000NoMan2000 Posts: 7Questions: 3Answers: 0

    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.

This discussion has been closed.