The following code does not update the current datatable row count correctly after applying filtering. Sometimes I have to hit the enter key twice in the filter input box after typing the text so the count is updated correctly. And sometimes it just works after I type the text and without pressing the enter key. Sometimes I can also just type the enter key once and the count is updated correctly. I don't understand why I get this different behavior. Perhaps a JSF / Primefaces expert could help me understand this?
<h:form id="summaryForm">
...
<p:tabView id="summaryTabView">
...
<p:tab id="allTab" title="All">
...
<script type="text/javascript">
//<![CDATA[
function updateAllRecordCount(){
var rowCount = PF('allTblWidget').paginator.cfg.rowCount;
//alert(rowCount);
var output = document.getElementById('summaryForm:summaryTabView:allTable:allCount');
if (output != null){
output.innerHTML = rowCount + " Records";
}
}
//]]>
</script>
<p:dataTable widgetVar="allTblWidget"
id="allTable"
var="pb"
value="#{statisticsBean.all}"
emptyMessage="No data available!"
rowKey="#{pb.rowId}"
scrollable="true" scrollHeight="440"
selection="#{statisticsBean.selectedBean}"
selectionMode="single"
editable="true"
editMode="cell"
paginator="true"
rows="300"
paginatorAlwaysVisible="false">
<p:ajax event="filter" oncomplete="updateAllRecordCount();"/>
<f:facet name="header">
<p:menubar styleClass="tableMenuClass">
...
<f:facet name="options">
<h:outputText id="allCount" style="font-size:14px;" value="#{statisticsBean.all.size()} Records"/>
</f:facet>
</p:menubar>
</f:facet>
...