jsf - Primefaces 数据表标题宽度 :auto

标签 jsf primefaces datatable

我正在使用 Primefaces 5 开发动态数据表。我已将表格宽度设置为自动。这真的很好。我的专栏只使用所需的宽度,这是完美的。但我也使用分页器和表头。所以我的表是这样的:
Dynamic datatable with header

<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>

如何强制页眉和分页器具有与表格相同的宽度?

最佳答案

对于普通数据表试试这个:

.ui-datatable {
    display: table;
}

.ui-datatable table {
    table-layout: auto !important;
}

我还没有尝试调整大小或其他任何东西。

关于jsf - Primefaces 数据表标题宽度 :auto,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25162117/

相关文章:

css - PrimeFaces DataTable 行着色不起作用

jsp - javax.el.MethodNotFoundException : Method not found: TableBeanDetail@bd4053. onRowSelect()

C# Winforms Bind ListBox to DataTable问题

C# 数据表 : Computing the average in a column

validation - 从实体类@Size值自动复制inputText maxlength

jsf - p :push not working with atmosphere spring boot

java - JSF 2.0 + PrimeFaces : dataTable page-numeration does not work

c# - 查询数据集中的 2 个数据表

javascript - JSF 中的 HTML 内容呈现

eclipse - 仅在 Eclipse : java. lang.IllegalStateException : No WebApplicationContext found: no ContextLoaderListener registered?