Skip to content

Commit

Permalink
Update: Support for DataTables 2's use of colgroup and col tags
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanJard committed Nov 28, 2023
1 parent ff9bb28 commit 500fd1b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions js/dataTables.responsive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 500fd1b

Please sign in to comment.