Skip to content

Commit

Permalink
6a96aa54cfbf2efbe12971426581eacfa9d9be6e Fix: Sizing of columns when …
Browse files Browse the repository at this point in the history
…scrolling is enabled

Need to set a min-width so the columns widths don't collapse down.

This is a continuation of DataTables/DataTablesSrc@fdc8a7f#diff-3ef3d2eb10c8d1c4610fb67d6ae25612f3b94e564a217f4f8cae634eb17731b4R165

and
DataTables/DataTablesSrc@3c4df03
.

None have yet covered all bases. This appears to work okay for the
testing done locally so far. Deploying to nightly for test

Sync to source repo @6a96aa54cfbf2efbe12971426581eacfa9d9be6e
  • Loading branch information
dtbuild committed Oct 14, 2024
1 parent 44558d6 commit 95f7821
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 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.8",
"last-sync": "265edd904b29f61d432da3b1f593b57773601083"
"last-sync": "6a96aa54cfbf2efbe12971426581eacfa9d9be6e"
}
7 changes: 7 additions & 0 deletions js/dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -2161,6 +2161,10 @@
var width = _fnColumnsSumWidth(settings, [i], false, false);

cols[i].colEl.css('width', width);

if (settings.oScroll.sX) {
cols[i].colEl.css('min-width', width);
}
}
}

Expand Down Expand Up @@ -5405,11 +5409,14 @@

if ( width ) {
this.style.width = width;
console.log(width, this.style.width);

// For scrollX we need to force the column width otherwise the
// browser will collapse it. If this width is smaller than the
// width the column requires, then it will have no effect
if ( scrollX ) {
this.style.minWidth = width;

$( this ).append( $('<div/>').css( {
width: width,
margin: 0,
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.

7 changes: 7 additions & 0 deletions js/dataTables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,10 @@ function _fnColumnSizes ( settings )
var width = _fnColumnsSumWidth(settings, [i], false, false);

cols[i].colEl.css('width', width);

if (settings.oScroll.sX) {
cols[i].colEl.css('min-width', width);
}
}
}

Expand Down Expand Up @@ -5352,11 +5356,14 @@ function _fnCalculateColumnWidths ( settings )

if ( width ) {
this.style.width = width;
console.log(width, this.style.width);

// For scrollX we need to force the column width otherwise the
// browser will collapse it. If this width is smaller than the
// width the column requires, then it will have no effect
if ( scrollX ) {
this.style.minWidth = width;

$( this ).append( $('<div/>').css( {
width: width,
margin: 0,
Expand Down

0 comments on commit 95f7821

Please sign in to comment.