【问题标题】:bAutoWidth not working when dataTable.bootstrap.js is included in the webpage当 dataTable.bootstrap.js 包含在网页中时,bAutoWidth 不起作用
【发布时间】:2017-03-25 11:26:30
【问题描述】:

'bAutoWidth : false' ,当 dataTable.bootstrap.js 包含在网页中时不起作用。我需要在我的页面中使用 dataTable.bootstrap.js 进行设计。如何解决?

$('#table').DataTable({
    "bAutoWidth": false,
    "columnDefs": [{
            "targets": [-1],
            "orderable": false
        }]
});

【问题讨论】:

  • 删除默认jquery.dataTables.css,当你使用dataTables.bootstrap.js/dataTables.bootstrap.css时不需要它,我猜这是导致冲突的原因(无论“不工作”是什么意思)
  • 删除 jquery.dataTables.css 没有帮助。我所说的“不工作”是指,即使 bAutoWidth 为 false,我也无法删除 dataTables 设置的自动宽度。在我的表格中,仍在为表格头(th)设置宽度。
  • 好的。听起来怪怪的。你能用小提琴复制这个吗......?这是一个起点(只需添加引导程序)jsfiddle.net/hqf4wrpq

标签: javascript jquery twitter-bootstrap datatables


【解决方案1】:

仅当您使用 columns.width 选项或通过 HTML/CSS 设置自己的列宽时,使用 autoWidth: false 才有意义。

您还使用了不带空格的单词,这会影响所有列的宽度。在桌子上使用table-layout: fixed 可能会有所帮助。

有关代码和演示,请参阅this example

【讨论】:

    猜你喜欢
    • 2021-04-07
    • 1970-01-01
    • 2016-01-06
    • 2013-05-15
    • 2015-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    相关资源
    最近更新 更多