The number of rows in the filtered data table

How to get the number of results after filtering in 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> 

There are ~ 20 columns in the table that you can sort and filter.

+4
source share
2 answers

Use the currentPageReportTemplate attribute of the p:dataTable :

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

Text outside curly braces can be changed.

+12
source

you can add ajax event to table

 <p:ajax event="filter" listener="#{bean.somemethod()}" update=":someId"/> 

there are other useful events for dating http://www.beyondjava.net/blog/primefaces-datatable-events

-1
source

Source: https://habr.com/ru/post/1346221/


All Articles