myesn

myEsn2E9

hi
github

Issue of reduced header column width when displaying DataTable in Bootstrap Modal

The issues in the title are as follows:
image

It can be seen that all columns are aligned to the left and some are even overlapping.

Solution:


const dataTable = $('#Table').DataTable(..);

$(document).on('shown.bs.modal', function () {
    // fix: When displaying DataTable in Bootstrap Modal, there is an issue with the narrowing of column widths
    // https://stackoverflow.com/a/43826114
    dataTable.columns.adjust();
});

Executing the above js code in the Modal will fix it.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.