From 9891660c94564b8122501df07fd8dbc53f5d24c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tak=C3=A1cs=20Eszter=20Magdolna?= Date: Tue, 19 Nov 2019 09:58:37 +0100 Subject: [PATCH] Bugfix: Avoid "Uncaught TypeError: Cannot read property 'sWidth' of undefined" while using column hider function (for example datatables.net-buttons/colVis). --- js/core/core.scrolling.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/core/core.scrolling.js b/js/core/core.scrolling.js index c2f814725..0d204b401 100644 --- a/js/core/core.scrolling.js +++ b/js/core/core.scrolling.js @@ -129,7 +129,7 @@ function _fnFeatureHtmlTable ( settings ) } $(scrollBody).css( - scrollY && scroll.bCollapse ? 'max-height' : 'height', + scrollY && scroll.bCollapse ? 'max-height' : 'height', scrollY ); @@ -210,7 +210,7 @@ function _fnScrollDraw ( settings ) // adjust the column sizes as the table width will have changed to account // for the scrollbar var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight; - + if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) { settings.scrollBarVis = scrollBarVis; _fnAdjustColumnSizing( settings ); @@ -255,7 +255,10 @@ function _fnScrollDraw ( settings ) $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) { idx = _fnVisibleToColumnIndex( settings, i ); - el.style.width = settings.aoColumns[idx].sWidth; + var column = settings.aoColumns[idx]; + if(column != null){ + el.style.width = column.sWidth; + } } ); if ( footer ) {