在PrimeFaces中使用可调整大小的列进行自动换行

时间:2015-03-04 05:18:47

标签: jsf-2 primefaces datatable

我正在使用PrimeFaces dataTable。我需要列标题进行自动换行并且可以调整大小。以下是我的问题:

  • 当我执行styleClass="wrap" resizableColumns="true"时,只能调整大小 正在努力。
  • 当我styleClass="wrap" resizableColumns="false"时,只有自动换行才有效。

我的代码是:

<p:dataTable id="transitCycleHighLevelDataTable" var="record"
    value="#{transitCycleMB.highLevel}" rowKey="#{record.group}"
    paginator="true" paginatorPosition="bottom" rows="10"
    styleClass="wrap" resizableColumns="true" scrollable="true"
    scrollWidth="100%" scrollHeight="250"
    rowsPerPageTemplate="10,20,50"
    paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {RowsPerPageDropdown} {NextPageLink} {LastPageLink} {Exporters}"
    currentPageReportTemplate="(Displaying {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})">

1 个答案:

答案 0 :(得分:0)

将此样式添加到dataTable中将使列标题可以换行并且列的大小可调整:

.ui-datatable thead th {
   white-space: normal !important;
}

注意:此功能已经过测试,可在PrimeFaces 6.2上运行。