You need to sign in to do that
Don't have an account?
Compass 1
How to Add grand total row in Visualforce Page
I have created a VF page to show the Opportunity data in PDF Output.
How I can add the Grand Total field on my VF Page. For reference please find below the code I have given to show the columns.
I wanted to show the total of Revenue Column.
<apex:datatable value="{!opportunityList}" var="opp" width="100%" styleClass="tableClass" border="1">
<apex:column value="{!opp.account.name}" headerClass="headerstyle" headerValue="Client"/>
<apex:column value="{!opp.name}" headerClass="headerstyle" headerValue="Project Title"/>
<apex:column style="width:75px" value="{!opp.Facility__c}" headerClass="headerstyle" headerValue="Facility"/>
<apex:column value="{!opp.Scope_Of_Work__c}" headerClass="headerstyle" headerValue="Scope Of Work"/>
<apex:column value="{!opp.Pricing_Type__c}" headerClass="headerstyle" headerValue="Pricing Type"/>
<apex:column style="width:90px" value="{!opp.BiddingStatus__c}" headerClass="headerstyle" headerValue="Bidding Status"/>
<apex:column style="width:90px;text-align:center" value="{!opp.Estimated_Revenue_MM__c}" headerClass="headerstyle" headerValue="Revenue"/>
</apex:datatable>
How I can add the Grand Total field on my VF Page. For reference please find below the code I have given to show the columns.
I wanted to show the total of Revenue Column.
<apex:datatable value="{!opportunityList}" var="opp" width="100%" styleClass="tableClass" border="1">
<apex:column value="{!opp.account.name}" headerClass="headerstyle" headerValue="Client"/>
<apex:column value="{!opp.name}" headerClass="headerstyle" headerValue="Project Title"/>
<apex:column style="width:75px" value="{!opp.Facility__c}" headerClass="headerstyle" headerValue="Facility"/>
<apex:column value="{!opp.Scope_Of_Work__c}" headerClass="headerstyle" headerValue="Scope Of Work"/>
<apex:column value="{!opp.Pricing_Type__c}" headerClass="headerstyle" headerValue="Pricing Type"/>
<apex:column style="width:90px" value="{!opp.BiddingStatus__c}" headerClass="headerstyle" headerValue="Bidding Status"/>
<apex:column style="width:90px;text-align:center" value="{!opp.Estimated_Revenue_MM__c}" headerClass="headerstyle" headerValue="Revenue"/>
</apex:datatable>
Can you please try below mentioned code?
<apex:datatable value="{!opportunityList}" var="opp" width="100%" styleClass="tableClass" border="1">
<apex:column value="{!opp.account.name}" headerClass="headerstyle" headerValue="Client"/>
<apex:column value="{!opp.name}" headerClass="headerstyle" headerValue="Project Title"/>
<apex:column style="width:75px" value="{!opp.Facility__c}" headerClass="headerstyle" headerValue="Facility"/>
<apex:column value="{!opp.Scope_Of_Work__c}" headerClass="headerstyle" headerValue="Scope Of Work"/>
<apex:column value="{!opp.Pricing_Type__c}" headerClass="headerstyle" headerValue="Pricing Type"/>
<apex:column style="width:90px" value="{!opp.BiddingStatus__c}" headerClass="headerstyle" headerValue="Bidding Status"/>
<apex:column style="width:90px;text-align:center" headerClass="headerstyle">
{!opp.Estimated_Revenue_MM__c}
<apex:facet name="header">Revenue</apex:facet>
<apex:facet name = "footer">{!total}</apex:facet>
</apex:datatable>
You should replace the {!total} with your controller variables which depicts the grand total.
After <table>, iterate over the list with <apex:repeat> and have one <tr> for each list item.
With in <tr>, use another <apex:repeat> to iterate over a list of fields and display the field value using a <td>.