制表符 fitData 布局未调整 table 的宽度

Tabulator fitData layout not resizing width of table

我正在尝试将 Tabulator v4.6.3 与 fitData 布局一起使用。这是我的代码:

var table = new Tabulator("#cowTable", {
        data: cowTableData,
        layout: "fitData",
        history: true,
        columns: [
            { title: "Cow ID", field: "cowId", editor: "number", editorParams: { step: 1 } },
            { title: "Enter", field: "enter", editor: "number", editorParams: { step: 100 } },
            { title: "Exit", field: "exit", editor: "number", editorParams: { step: 100 } },
            { title: "Strip Status", field: "strip", editor: "select", editorParams: { "active": "Active", "inactive": "Inactive", "absent": "Absent" } },
            { title: "Mobility", field: "mobility", editor: "number", editorParams: { min: 0, max: 3, step: 0.05 } },
            { title: "Body Condition", field: "bodycond", editor: "number", editorParams: { min: 0, max: 4, step: 0.05 } }
        ]

产生这个: 我的问题是右侧的黑色部分似乎 table 未正确调整大小。每当我使用布局选项 fitColumns 时,它工作正常并且是下图的全宽但列太宽了。 我尝试在 table 的代码下方执行 table.redraw(),但这并没有解决任何问题。 如果有人有解决办法把右边的黑色部分去掉,将不胜感激。

谢谢。

渲染正确。

fitData 布局模式中,列会调整大小以适应它们的 data/column 标题,这正是那里发生的事情,并且右边的备用 space 则为空。

如果你想填充空白 space 那么你应该使用 fitDataFill fitDataStretch 布局模式。

Taubulator 网站在 Layout Examples Section

中提供了每种布局模式的示例