数据表固定列未在 bootstrap 模式中对齐

datatables fixed column not aligning in bootstrap modal

我正在使用 js 数据tables。我在模态中有一个 table,我正在尝试使最左边的列固定。下面是我的数据脚本tables.

$('#table1').DataTable({
"dom": 'Bfrtip',
"bPaginate": false,
"bLengthChange": false,
"bInfo": false,
"bFilter": false,
"buttons": [{
    extend: 'excelHtml5',
    title: 'Excel1',
    sheetName: 'Sheet1'
}],
scrollY:        300,
scrollX:        true,
scrollCollapse: true,
paging:         false,
fixedColumns:   true
"ordering": false
});

除固定列外一切正常。我已经包括固定列 css 和 Js.

实际问题是,当我应用固定列时,table 会缩小。

您必须在 table 属性(而不是 css 中)

中显式地具有 ' style="width:100%"

试一试:

$('#modal_ID').on('shown.bs.modal', function (e) {
  $($.fn.dataTable.tables(true)).DataTable().columns.adjust();});