From 500fd1bc64639e733ca3ebf72996c7d05069447d Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Tue, 28 Nov 2023 14:47:55 +0000 Subject: [PATCH] Update: Support for DataTables 2's use of `colgroup` and `col` tags --- js/dataTables.responsive.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/js/dataTables.responsive.js b/js/dataTables.responsive.js index cb3754b..a4fad51 100644 --- a/js/dataTables.responsive.js +++ b/js/dataTables.responsive.js @@ -122,10 +122,9 @@ $.extend(Responsive.prototype, { dt.settings()[0]._responsive = this; - // Use DataTables' throttle function to avoid processor thrashing on - // resize + // Use DataTables' throttle function to avoid processor thrashing $(window).on( - 'resize.dtr orientationchange.dtr', + 'orientationchange.dtr', DataTable.util.throttle(function () { // iOS has a bug whereby resize can fire when only scrolling // See: http://stackoverflow.com/questions/8898412 @@ -941,6 +940,13 @@ $.extend(Responsive.prototype, { changed = true; that._setColumnVis(colIdx, columnsVis[i]); } + + // DataTables 2 uses `col` to define the width for a column + // and this needs to run each time, as DataTables will change + // the column width + if (! columnsVis[i]) { + $('colgroup > col', dt.table().node()).eq(visible).css('width', 0); + } }); if (changed) {