Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 758
meyquel Avatar asked Apr 09 '13 13:04

meyquel


1 Answers

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.

like image 197
partlov Avatar answered Nov 15 '22 22:11

partlov