7

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

不同宽度

代码:

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, ...
                        ]);
4

1 回答 1

3

禁用自动列宽。

JS

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

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

于 2015-07-11T10:07:55.200 回答