Dom*_*ser 8 datatable jsf primefaces
我正在使用Primefaces 5开发动态数据表.我已将表格宽度设置为auto.这真的很好.我的专栏仅使用所需的宽度,这是完美的.但我也使用paginator和Table标头.所以我的表看起来像这样:

<p:dataTable var="row"
editingRow="#{row.status == CommonConstant.ROWSTATUS_EDIT}"
tableStyle="width:auto"
value="#{componentBean.componentData[componentId].lazyModel}"
id="#{componentId}"
editable="true" scrollable="false" scrollHeight="100%"
resizableColumns="true"
paginator="true"
paginatorPosition="top"
rowsPerPageTemplate="10 25 50 100"
lazy="true">
<f:facet name="header">
<p:outputPanel style="text-align:right">
<h:commandLink rendered="#{fn:indexOf(componentBean.componentData[componentId].loadedData.actions, CommonConstant.ACTIONTYPE_EXCEL) >= 0}" >
<img border="0" src="img/excel.png" width="24"/>
<p:dataExporter type="xls" target="#{componentId}" fileName="#{appDialogId}" />
</h:commandLink>
<h:commandLink rendered="#{fn:indexOf(componentBean.componentData[componentId].loadedData.actions, CommonConstant.ACTIONTYPE_PDF) >= 0}">
<img border="0" src="img/pdf.png" width="24"/>
<p:dataExporter type="pdf" target="#{componentId}" fileName="#{appDialogId}"/>
</h:commandLink>
</p:outputPanel>
<p:outputPanel>
<h:outputText value="#{componentBean.componentData[componentId].loadedData.appdialogid}" />
</p:outputPanel>
</f:facet>
...
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
如何强制Header和paginator具有与表相同的宽度?
对于普通数据表,试试这个:
.ui-datatable {
display: table;
}
.ui-datatable table {
table-layout: auto !important;
}
Run Code Online (Sandbox Code Playgroud)
我还没有尝试过resizable或其他任何东西.

我假设您正在数据表上设置自动宽度,因为我可以重新创建您的问题。
尝试这个:
注意:表格元素的宽度需要保持为默认值 100%,以便填充标题。
下面的内容并不真正相关,但仍然“很高兴知道”。
Primefaces 5 中的所有数据表均使用表布局:固定。您可以使用 css 进行覆盖以匹配较旧的 Primefaces 模型。
.ui-datatable table, .ui-datatable-resizable table {
table-layout: auto !important;
}
.ui-datatable-scrollable table {
table-layout: fixed !important;
}
Run Code Online (Sandbox Code Playgroud)
可滚动数据表需要保持固定。
如果您删除输出面板并使用链接的数据导出器方面可能会有所帮助。如果您喜欢标题中的链接,请将它们放在跨度中。
<f:facet name="{Exporters}">
<h:commandLink> ...
</h:commandLink> ...
</f:facet>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
26855 次 |
| 最近记录: |