Skip to content

Commit

Permalink
3c4df03c5e03c4c743fb5bdf0067ab3462a723e4 Fix: Column widths given by …
Browse files Browse the repository at this point in the history
…`-init columns.width` will now increase a column's size if needed.

https://datatables.net/forums/discussion/79737/

Sync to source repo @3c4df03c5e03c4c743fb5bdf0067ab3462a723e4
  • Loading branch information
dtbuild committed Aug 28, 2024
1 parent fccf4ef commit 37c1744
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
],
"src-repo": "http://github.com/DataTables/DataTablesSrc",
"last-tag": "2.1.4",
"last-sync": "b11d4b03ca9875b9ac1c281cbeb624aeea21989d"
"last-sync": "3c4df03c5e03c4c743fb5bdf0067ab3462a723e4"
}
10 changes: 9 additions & 1 deletion js/dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,11 @@
for (var i=0 ; i<cols.length ; i++) {
var width = _fnColumnsSumWidth(settings, [i], false, false);

cols[i].colEl.css('width', width);
// Need to set the min-width, otherwise the browser might try to collapse
// it further
cols[i].colEl
.css('width', width)
.css('min-width', width);
}
}

Expand Down Expand Up @@ -5400,7 +5404,11 @@
var width = _fnColumnsSumWidth( settings, this, true, false );

if ( width ) {
// Need to set the width and min-width, otherwise the browser
// will attempt to collapse the table beyond want might have
// been specified
this.style.width = width;
this.style.minWidth = width;

// For scrollX we need to force the column width otherwise the
// browser will collapse it. If this width is smaller than the
Expand Down
2 changes: 1 addition & 1 deletion js/dataTables.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dataTables.min.mjs

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion js/dataTables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,11 @@ function _fnColumnSizes ( settings )
for (var i=0 ; i<cols.length ; i++) {
var width = _fnColumnsSumWidth(settings, [i], false, false);

cols[i].colEl.css('width', width);
// Need to set the min-width, otherwise the browser might try to collapse
// it further
cols[i].colEl
.css('width', width)
.css('min-width', width);
}
}

Expand Down Expand Up @@ -5347,7 +5351,11 @@ function _fnCalculateColumnWidths ( settings )
var width = _fnColumnsSumWidth( settings, this, true, false );

if ( width ) {
// Need to set the width and min-width, otherwise the browser
// will attempt to collapse the table beyond want might have
// been specified
this.style.width = width;
this.style.minWidth = width;

// For scrollX we need to force the column width otherwise the
// browser will collapse it. If this width is smaller than the
Expand Down

0 comments on commit 37c1744

Please sign in to comment.