如何自定义从PrimeFaces DataTable中的分页程序(How to customize

2019-07-31 04:44发布

我想自定义PrimeFace的数据表分页。

它目前示出在底部作为页面计数: (1 of 5) 我想在一个页面中显示的记录#满分记录总数,如: (1-10 of 50)

我已经包含下面我的代码 - 但它无法正常工作。 谁能请帮助?

<p:dataTable id="tblStatusSearch" var="item" rowIndexVar="rowStatusSearch"      
    rows="10" paginator="true"  
    paginatorTemplate="{CurrentPageReport}  
    {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
    value="#{StatusAction.listEBeans}"

<f:facet name="footer"> 
    <h:outputText value="#{rowStatusSearch + 1} - 10 out of #{bondLocationStatusAction.itemCount}"/>
</f:facet>

Answer 1:

您可以使用PrimeFaces currentPageReportTemplate像这样的CurrentPageReport:

<p:dataTable id="tblStatusSearch" var="item" paginator="true" rows="10"
    currentPageReportTemplate="Showing {startRecord}-{endRecord} out of {totalRecords}"
    paginatorTemplate="{CurrentPageReport}  
{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
    value="#{StatusAction.listEBeans}">

我确认它工作在PrimeFaces 3.4.2。 这是出现在用户指南PrimeFaces 3.0,因此,如果您正在使用PrimeFaces 3.x中它应该为你工作。



Answer 2:

这将解决你的目的,我认为。

<p:dataTable id="datatable" var="car" value="#{myBean.cars}" paginator="true" rows="10"  
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {CurrentPageReport}"
currentPageReportTemplate="{startRecord} - {endRecord} of {totalRecords}">
<p:column...../>
<p:column...../>
</p:datatable>    

在地方{} CurrentPageReport的,你将能够看到你在找什么。



Answer 3:

"please refer to the attached image"我想你已经忘记附加图像;)

如果你想显示在你的页面大小p:datatable ,你应该在你的bean声明两个领域并保持pageSizefirst参数值构成load方法中他们则可以显示与下面的页面大小paginatorTemplate

paginatorTemplate=" {CurrentPageReport} #{yourBean.first + yourBean.pageSize} and rest of you template "

记得EL工作在paginatorTemplate财产。



文章来源: How to customize the paginator from PrimeFaces datatable