我使用jsf并有一个启用过滤的primefaces数据表。
<p:dataTable value="#{tcsInstanceBean.tcsJList}" var="return" scrollable="true" scrollHeight="550"
widgetVar="returnTable"
emptyMessage="Nothing found matching given criteria"
filteredValue="#{tcsInstanceBean.filteredTcsJList}"
styleClass="returnTable, selectable"
headerClass="returnTableHeader"
rowClasses="returnTableOddRow,returnTableEvenRow"
resizableColumns="true">
<p:column class="returnColumn" style="width:40%;"
sortBy="#{return.path}"
filterBy="#{return.path.fileName}"
filterMatchMode="contains">
<f:facet name="header">Job Path</f:facet>
<a href="file:///#{return.path}" target="_blank">#{return.path.fileName}</a>
</p:column>
</p:dataTable>
我希望在过滤后输出所有可见的总行数。 目前我只计算清单并输出它。
jobsCounter = "We found " + tcsJList.size() + " Jobs!";
如何在过滤后计算所有可见行?
答案 0 :(得分:0)
编写类似
的方法public int count(){
if(getTcsInstanceBean().filteredTcsJList!=null){
return getTcsInstanceBean().filteredTcsJList.size();
}
else {
return getcsInstanceBean().tcsJList.size();
}
}
或使用currentPageReportTemplate
<p:dataTable value="#{tcsInstanceBean.tcsJList}" var="return" scrollable="true" scrollHeight="550"
widgetVar="returnTable"
emptyMessage="Nothing found matching given criteria"
filteredValue="#{tcsInstanceBean.filteredTcsJList}"
styleClass="returnTable, selectable"
headerClass="returnTableHeader"
rowClasses="returnTableOddRow,returnTableEvenRow"
resizableColumns="true"
paginator="true"
paginatorTemplate="{CurrentPageReport}"
currentPageReportTemplate="We found {totalRecords}, Jobs!">
<p:column class="returnColumn" style="width:40%;"
sortBy="#{return.path}"
filterBy="#{return.path.fileName}"
filterMatchMode="contains">
<f:facet name="header">Job Path</f:facet>
<a href="file:///#{return.path}" target="_blank">#{return.path.fileName}</a>
</p:column>
</p:dataTable>