meyquel
meyquel

Reputation: 2214

How can I capture the event filtering a datatable in primefaces

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

Answers (1)

partlov
partlov

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

Related Questions