水平滚动时,datatables标题与列不对齐

时间:2016-07-12 19:23:19

标签: datatables

我无法弄清楚解决这个问题的方法。我试过添加" table-layout:fixed"但它不再适用于当前版本。

由于

var config = {
        "bFilter": false,           
        "bInfo": false,
        "bPaginate": true,
         "scrollY": 200,
         "table-layout":fixed,
        "data": dataoMine, 
        "bAutoWidth": false,
        "columns": columns,
        "scroller": true,
        "language": {
            "emptyTable": "empty data"
        }, 
        "columnDefs": [
            {"className": "dt-center", "targets": "_all"}
        ]       
    };

enter image description here

<table class="dataTable" style="width:80%; height:100%; margin-left:10%; margin-right:10%;}">
<thead><tr>
    <th>a1</th>
    <th>a2</th> 
    <th>a3</th>
    <th>a4</th>
    <th>a5</th>
    <th>a6</th>
    <th>a7</th>
    <th>a8</th>
</tr></thead>
</table>

3 个答案:

答案 0 :(得分:0)

我没有足够的信息给你一个坚定的答案,因为你没有告诉我们columns变量中的内容,也没有告诉我们dataoMine数组的结构。但是,从您的屏幕截图中可以清楚地看出,您有四列数据,并且还指定了八列。这将显示缺少数据列的所有列和背景。据推测,您的“理发店条纹”是您正在使用的任何主题的页面背景。

确保您的数据中列数与列规范中的列数相同,并查看是否可以解决您的问题。

答案 1 :(得分:0)

经过研究发现,这个问题非常普遍。似乎没有确定的解决方案,但这对我有用:

将此添加到dt的配置中:

scrollX:100%

答案 2 :(得分:0)

我只需添加即可解决我的问题

scrollX:是

相关问题