function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JimmyMacJimmyMac 

Creating a Total Line in a <apex:pageBlockTable>....

I need to total up a column in a <apex:pageBlockTable and display it at the bottom (I want it inside the pageBlockTable not out of it).

 

The code to create the Total is done, I just need to put the value inside the <apex:pageBlockTable at the bottom.

 

Is there a way while looping through the <apex:pageBlockTable to check for EOF condition. If there is, then I could use that to check in the RENDERED attribute and only

show the total column if EOF is true.

 

Thanks to all in advance!

-Jim

SurekaSureka

Hey,

 

Sample Solution:

 

public List<Contact> getAccs()
{
    List<Contact> contacts = [select Primary_Extension__c from Contact];
    Decimal total=0;
    for(Contact con: contacts )
    {
        if(con.Primary_Extension__c!=null)
        total = total+con.Primary_Extension__c;
    }
    Contact c = new Contact();
    c.Primary_Extension__c = total;
    contacts.add(c);
    return contacts;
}

 

In the above exaple, I am displaying only the primary extension in Page block table of Visualforce. If you have other fields, assign appropriate values to the other fields.

 

Thanks

JimmyMacJimmyMac

Thanks but that isn't what my issue was, I already have the total information, it was in the display logic on the apex page that I was asking aout.

 

I think I found something, I need to use the apex footer attribute and put the total amount in there.