Skip to content

Commit b581e36

Browse files
authored
Merge pull request #5771 from Laravel-Backpack/fix-responsive-controls-on-table-resize
fix responsive table on resize
2 parents bb6cd6c + 63d9f8c commit b581e36

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/resources/views/crud/inc/datatables_logic.blade.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,20 @@ functionsToRunOnDataTablesDrawEvent: [],
398398
// the table should have the has-hidden-columns class
399399
crud.table.on( 'responsive-resize', function ( e, datatable, columns ) {
400400
if (crud.table.responsive.hasHidden()) {
401+
let firstVisibleColumn = $('.dtr-control').closest('tr').find('td').filter(function() {
402+
return $(this).is(':visible');
403+
}).first();
404+
405+
// move the dtr-control to the first visible column
406+
$('.dtr-control').prependTo(firstVisibleColumn);
401407
$('.dtr-control').removeClass('d-none');
402408
$('.dtr-control').addClass('d-inline');
403409
$("#crudTable").removeClass('has-hidden-columns').addClass('has-hidden-columns');
404-
} else {
405-
$('.dtr-control').removeClass('d-none').removeClass('d-inline').addClass('d-none');
406-
$("#crudTable").removeClass('has-hidden-columns');
407-
}
408-
} );
410+
} else {
411+
$('.dtr-control').removeClass('d-none').removeClass('d-inline').addClass('d-none');
412+
$("#crudTable").removeClass('has-hidden-columns');
413+
}
414+
});
409415
@else
410416
// make sure the column headings have the same width as the actual columns
411417
// after the user manually resizes the window

0 commit comments

Comments
 (0)