Skip to main content
Hello, 

I have a pageBlockTable that returns a list of records, but how can I sum the column values at the bottom?  Do I need to create an extension to my controller?  Or is there a way I can sum the values "on the fly"?

Here is my table: 

 

<apex:pageBlockTable value="{!listOfCO}" var="co">

<apex:column value="{!co.Buyer_Name__c}"/>

<apex:column value="{!co.Total_Order__c}"/>

<apex:column value="{!co.Balance_to_Collect__c}"/>

</apex:pageBlockTable>

I would really appreciate any help!

Thanks, 

John

 
6 件の回答
  1. 2015年4月12日 23:58
    I'm not sure how you would like to show the total so I have just added a line below the table:

    <apex:variable var="totalBalance" value="{!0}"/>

    <apex:pageBlockTable value="{!listOfCO}" var="co">

       <apex:column value="{!co.Buyer_Name__c}"/>

       <apex:column value="{!co.Total_Order__c}"/>

       <apex:column headerValue="Balance to Collect">

          <apex:outputField value="{!co.Balance_to_Collect__c}"/>

          <apex:variable var="totalBalance" value="{!totalBalance+co.Balance_to_Collect__c}"/>

       </apex:column/>

    </apex:pageBlockTable>

    <apex:outputText value="{0, number, 0.00}">

       <apex:param value="{!totalBalance}" />

    </apex:outputText>
0/9000