JS dataTables.fixedHeader标头和数据之间的宽度不同

时间:2015-07-02 12:34:17

标签: javascript html datatable fixed-header-tables

我使用javascript插件dataTables.fixedHeader并用ajax填充数据。 现在我遇到了问题,每个数据列的宽度是动态的,并且标题保持在相同的静态宽度。

Different width

代码:

HTML:

<table class="table table-striped table-bordered table-hover" id="custTable">
                    <thead>
                        <tr>
                            <th>
                                ......
                            </th>
                            <th>
                                ......
                            </th>
                            <th>
                                ......
                            </th>
......
                        </tr>
                    </thead>
                    <tbody id="dataList"></tbody>
                </table>

JS:

table = $('#custTable').DataTable({
            "dom": "frtiS",
            "deferRender": true,
        });

填写:

$('#custTable').dataTable().fnAddData([
               xyz, xyz, xyz, ...
                        ]);

1 个答案:

答案 0 :(得分:3)

禁用自动列宽。

<强> JS

table = $('#custTable').DataTable({
            "dom": "frtiS",
            "deferRender": true,
            "autoWidth": false
        });

http://datatables.net/reference/option/autoWidth

相关问题