我有一个丰富的数据表,其中包含可以过滤的列。
<!-- Data table with filters -->
<h:form>
<rich:dataTable value="#{sessionScope.paymentsBean.payments}" var="payment"
id="table">
<rich:column filterBy="#{sessionScope.payment.invoice}" filterEvent="onkeyup">
<f:facet name="header">Invoice</f:facet>
<h:outputText value="#{sessionScope.payment.invoice}" />
</rich:column>
<rich:column filterBy="#{sessionScope.payment.description}" filterEvent="onkeyup">
<f:facet name="header">Description</f:facet>
<h:outputText value="#{sessionScope.payment.description}" />
</rich:column>
<rich:column filterBy="#{sessionScope.payment.amount}" filterEvent="onkeyup">
<f:facet name="header">Amount</f:facet>
<h:outputText value="#{sessionScope.payment.amount}" />
</rich:column>
</rich:dataTable>
</h:form>
<!-- Total -->
<h:outputText id="total" value="#{sessionScope.paymentsBean.total}" >
<f:convertNumber maxFractionDigits="2" type="currency" currencySymbol="$"/>
</h:outputText>
对于总数,我可以将 sessionScope.paymentsBean.payments 中的所有金额相加得到总数。在以下示例中为 355.00 美元。
Invoice Description Amount
1 Cash $5.00
2 Visa $50.00
3 Visa $100.00
4 MasterCard $200.00
Total: $355.00
但是,如果我按“签证”过滤,表格和总数将如下所示:
Invoice Description Amount
2 Visa $50.00
3 Visa $100.00
Total: $355.00
总额应该是 150 美元,但 getTotal() 不知道 filterBy 数据。有没有办法根据rich:datatable中的filterBy标准动态计算总数?