Reputation: 2214
How can I capture the event filtering a p:dataTable
in PrimeFaces. I need to calculate some values associated with the results list when filtered and I have to do the calculations using the filtering table:
<p:dataTable id="tabla_gral" rendered="#{consumoMaterial.verTabla}" var="item"
paginator="true" rows="15" rowKey="#{item.no}"
value="#{consumoMaterial.listadoConsumo}"
filteredValue="#{consumoMaterial.listadoConsumoFiltered}">
But I want to do the calculation every time you use the filtrate.
Upvotes: 10
Views: 23919
Reputation: 14277
Primefaces p:dataTable
has AJAX event filter
which you can define on p:dataTable
:
<p:dataTable>
<p:ajax event="filter" listener="#{myBean.filterListener}"/>
</p:dataTable>
Now in your backing bean define method filterListener
:
public void filterListener(FilterEvent filterEvent) {
// your code here...
}
Now, your filterListener
function will be called on every filter event.
Upvotes: 26