【发布时间】:2016-12-15 14:46:38
【问题描述】:
我希望表格的列将其宽度调整为最大元素。 就像双击一个 excel 列...
我尝试了很多其他问题的属性和解决方案,但没有真正达到我想要的效果。
这是我对嵌套在 p:scollPanel 中的 dataTable 的设置:
<p:dataTable scrollable="true" scrollWidth="auto" scrollHeight="390"
tableStyle="width: auto; white-space: nowrap; font-size: smaller"
id=carTable" var="vehicles"
value="#{dgBean.vehicles}">
使用:
- primefaces 6.0
- jsf 2.2.1
更新:
我不知道为什么,但似乎没有使用 table-layout: auto 并且生成了两个 div。 1 用于我的表的标题,另一个用于我的表的主体。 这就是为什么我发布的第一个布局显示出来并且标题和正文很好地适合它们自己,但标题不适合正文。
生成的 HTML:
<div class="ui-widget-header ui-datatable-scrollable-header" style="width: 1199px;">
<div class="ui-datatable-scrollable-header-box" style="margin-right: 15px;">
<table role="grid">
<thead id="j_idt5:j_idt14:carTable_head">...</thead>
</table>
</div>
</div>
<div class="ui-datatable-scrollable-body" tabindex="-1" style="height: 390px; margin-right: 0px; width: 1199px;">
<table role="grid">
<thead class="ui-datatable-scrollable-theadclone" style="height: 0px;">...</thead>
<tbody id="j_idt5:j_idt14:carTable_data" class="ui-datatable-data ui-widget-content" tabindex="0">...</tbody>
</table>
</div>
所以似乎生成了 2 个表。有谁知道如何使用 pf 解决这个问题?
评论更新
申请
.ui-datatable-scrollable-header-box table, .ui-datatable-scrollable-footer-box table, .ui-datatable-scrollable-body table {
table-layout: auto;
}
到Showcase 产生(删除了我以前的图像,因为声誉不够高超过 2):
【问题讨论】:
-
去掉自定义css还能用吗?
-
@Kukeltje 我猜你的意思是 primefaces 主题?不,它不会改变任何事情
-
没有 tableStyle 的东西,如果它仍然不起作用,请检查问题列表并尝试更新版本(尝试,仅针对此问题)
-
我添加了一张没有 tableStyle 元素的图片。新的 pf 版本?我稍后再试,现在很忙:-)
-
我已经尝试过更新版本,现在正在运行 6.0。没有改变任何事情。我也找不到类似情况的问题 :-( 通过将 scrollWidth 设置为 250% 以放大所有列来绕过它,但这仍然不是我想要的
标签: jsf primefaces