Html Primefaces组表手动设置列宽
我使用Primefaces 5和一个包含150多列的组数据表。我正在尝试手动设置每个列宽。我在这里尝试了这些线程,但primefaces仍在自动调整列宽,以便在一个屏幕上显示所有列,而无需任何水平滚动。我正在寻找一个地方设置列宽在px或%。 我不知道如何使用组标题 到目前为止,我试过:Html Primefaces组表手动设置列宽,html,jsf-2,primefaces,Html,Jsf 2,Primefaces,我使用Primefaces 5和一个包含150多列的组数据表。我正在尝试手动设置每个列宽。我在这里尝试了这些线程,但primefaces仍在自动调整列宽,以便在一个屏幕上显示所有列,而无需任何水平滚动。我正在寻找一个地方设置列宽在px或%。 我不知道如何使用组标题 到目前为止,我试过: resizableColumns="true" style="table-layout: fixed" Set style="width:auto" and 在css中设置: .repoTab.ui-data
resizableColumns="true" style="table-layout: fixed"
Set style="width:auto" and
在css中设置:
.repoTab.ui-datatable table { width: auto !important; }
我的xhtml在这里:
<h:form>
<p:dataTable id="userTable" value="#{userDAO.data}" var="ub"
binding="#{userBean.dataTable}" paginator="true" rows="500"
resizableColumns="true" style="table-layout: fixed">
<f:facet name="header">
<p:toolbar>
<!-- Header Codes Here -->
</p:toolbar>
</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column colspan="3" headerText="Application" style="width:auto" />
<!-- <p:column colspan="6" headerText="Primary" width="100%" /> -->
</p:row>
<p:row>
<!-- ************ Application ************* -->
<p:column colspan="3" headerText="Key" style="width:auto" />
<!-- ************ Primary ************* -->
</p:row>
<p:row>
<!-- ************ Appl Key ************* -->
<p:column headerText="Id" width="50" />
<p:column headerText="F Name" width="150" />
<p:column headerText="L Name" width="150" />
</p:row>
</p:columnGroup>
<p:column headerText="Id" width="50">
<h:outputText value="#{userBean.dataTable.rowIndex+1}" />
</p:column>
<p:column headerText="First Name">
<h:outputText value="#{ub.firstName}" />
</p:column>
<p:column headerText="Last Name">
<h:outputText value="#{ub.lastName}" />
</p:column> -->
</p:dataTable>
</h:form>
</html>
-->
保持表格CSS样式:
.ui-datatable table { width: auto !important; }
删除宽度属性,并在列样式上设置最小宽度:
<p:columnGroup type="header">
<p:row>
<!-- ... -->
</p:row>
<p:row>
<p:column headerText="Id" style="min-width: 50px;" />
<p:column headerText="F Name" style="min-width: 150px;" />
<p:column headerText="L Name" style="min-width: 150px;" />
</p:row>
</p:columnGroup>
希望有帮助。我通过添加
expandableRowGroups=“true”
解决了这个问题,然后我可以使用style属性
<p:dataTable expandableRowGroups="true" scrollable="true" >
<p:columnGroup type="header">
<p:row>
<p:column rowspan="2" headerText="txt" style="width:50px;" />
</p:row>
</p:columnGroup>
</p:dataTable>
我发现,如果我添加任何列组,那么我就失去了为每个列提供的所有固定宽度设置。我不知道如何修复它。我在这里看到了与未解决的问题相同的问题:。ui datatable{width:auto!important;}应该可以工作。@vels4J,它不工作,我已经这样做了,并且在css中的set下提到过:另外,您可以使用width
value