简体   繁体   English

JQuery数据表 - 空表列标题被压扁

[英]JQuery Datatables - Empty table column headers are squished

I have a page with two dataTables. 我有一个包含两个dataTable的页面。 One of them is populated with data on page load, the other is empty (but skeletal, ie it has headers and empty <tbody> tag). 其中一个填充了页面加载的数据,另一个是空的(但是骨架,即它有标题和空<tbody>标记)。 The second table depends on the selection of a row in the first table. 第二个表取决于第一个表中行的选择。 Everything is working, and both tables are loading and displaying data like they should, with the exception of when the second table is empty. 一切正常,两个表都加载并显示数据,但第二个表为空时除外。

When it is empty, the headers appear thusly: 当它为空时,标题出现如此:

在此输入图像描述

Those headers have sWidth set for each, and when there is data to be displayed, they are the correct width and all is right with the world. 这些标题为每个标题设置了sWidth,当有数据要显示时,它们是正确的宽度,并且全部都是正确的。 I have, as yet, been unable to get them to behave with no data in the table. 到目前为止,我还没有让他们在表中没有数据的情况下表现出来。

Any assistance would be most appreciated. 任何援助都将非常感激。

Edit 编辑

I have tried bAutoWidth on and off (removing and adding explicit column widths in the aoColumns property. 我已经尝试打开和关闭bAutoWidth(在aoColumns属性中删除并添加显式列宽)。

I have also tried giving the <th> element an explicit width <th width="50px"> and tried setting a class on the <th> with an explicit width. 我也尝试给<th>元素一个明确的宽度<th width="50px">并尝试在<th>上设置一个具有显式宽度的类。 Additionally I tried wrapping the text in the th in a <span> and setting a width and then a style with a width. 另外,我尝试在<span>包装文本并设置宽度,然后设置宽度的样式。 Nothing has worked. 没有任何效果。 In fact, the <span> made it even worse, by collapsing the header row almost to 0. 实际上,通过将标题行几乎折叠为0, <span>使情况变得更糟。

Also, table-layout:fixed is set. 另外,table-layout:fixed设置。

Shooting in the dark. 在黑暗中拍摄。 Have you tried: 你有没有尝试过:

table {
    table-layout: fixed;
}

?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM