Footer right align in apex:pageBlockTable Salesforce

Footer right align in apex:pageBlockTable Salesforce

The CSS style float:right;, helps in Footer right align in apex:pageBlockTable.


Sample Code:


Visualforce page:


<apex:page docType=”html-5.0″ controller=”Sample”>
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value=”{!listAccount}” var=”a”>
            <apex:column value=”{!a.Name}”/>
            <apex:column value=”{!a.AnnualRevenue}” style=”text-align:right;”>
                <apex:facet name=”footer”>
                    <apex:outputText value=”${0, number, ###,###,###,##0.00}” style=”float:right;”>
                        <apex:param value=”{!totalRevenue}” />
                    </apex:outputText>
                </apex:facet>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>

</apex:page>


Controller:


public class Sample {
    public List<Account> listAccount {get;set;}
    public Double totalRevenue {get;set;}
    public Sample() {
        totalRevenue = 0;
        listAccount = [SELECT Name, AnnualRevenue FROM Account];
        calculateTotalRevenue();
    }
    private void calculateTotalRevenue() {
        for(Account acct : listAccount) {
            if(acct.AnnualRevenue != null)
                totalRevenue += acct.AnnualRevenue;
        }
    }
}

Output:




Cheers!!!

Leave a Reply