Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Row count in filtered DataTable

How can I get the number of results after filtering in a paged DataTable in PrimeFaces?

<p:dataTable id="tbl" var="x" value="#{dbBean.xSorted}" paginator="true" rows="20">
    <p:column sortBy="#{x.id}" filterBy="#{x.id}" filterMatchMode="exact">
        <f:facet name="header">
            <h:outputText value="ID" />
        </f:facet>
        <h:outputText value="#{x.id}" />
    </p:column>
</p:dataTable>

The table has ~20 columns which can be sorted and filtered.

like image 449
voglerr Avatar asked Dec 12 '22 14:12

voglerr


1 Answers

Use the currentPageReportTemplate attribute of the p:dataTable component:

<p:dataTable id="tbl" var="x" 
       value="#{dbBean.xSorted}" paginator="true" rows="20"
       currentPageReportTemplate="(Displaying {startRecord} - {endRecord} of 
       {totalRecords}, Page: {currentPage}/{totalPages})">
 ...
</p:dataTable>

The text outside curly brackets can be changed.

like image 57
Matt Handy Avatar answered Feb 20 '23 03:02

Matt Handy