You need to sign in to do that
Don't have an account?
Hugo Stoupe
Using a variable on a VF page to sum up values from a LIST of data and display on the page.
I am making a time entry report in a visualforce page that looks up records (hours in a week); based on a start / finish day and then displays the time in a grid format.
Is there a way that I can use a variable on the page to store the hours in each week that is written to the page and then at the bottom of the "Grid" show a total for each day. I would then also want another variable "grandtotal" to display the total hours of all days.
Below is a screen shot of the page and the visual force code that follows.
Is there a way that I can use a variable on the page to store the hours in each week that is written to the page and then at the bottom of the "Grid" show a total for each day. I would then also want another variable "grandtotal" to display the total hours of all days.
Below is a screen shot of the page and the visual force code that follows.
<apex:page controller="selectAllSOQLExampleController" tabStyle="Account" docType="HTML-5.0"> <apex:form > <apex:pageBlock > <apex:pageBlockButtons > <b>Starting (yyyy-mm-dd): </b> <apex:inputText size="10" id="startDate" value="{!startDate}"/> <b>Ending (yyyy-mm-dd):</b> <apex:inputText size="10" id="endDate" value="{!endDate}"/> <apex:commandButton value="Fetch Time Entries" action="{!fetch}"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1" title="Dynamic SOQL Query" collapsible="True"> <apex:outputText value="{!query}"> </apex:outputText> </apex:pageBlockSection> <apex:pageBlockSection title="Billable Docket Report" columns="1" collapsible="False">Test <apex:pageBlockTable value="{!TEList}" var="tec"> <apex:column width="10" title="Week Starting" value="{!tec.Monday_Date__c}"/> <apex:column width="30" value="{!tec.Functional_Area__c}"/> <apex:column width="20" value="{!tec.Standard_Activities__c}"/> <apex:column value="{!tec.Activity_Other__c}"/> <apex:column width="10" value="{!tec.Project__c}"/> <apex:column width="10" value="{!tec.Contract__c}"/> <apex:column width="10" headerValue="Mon"> <apex:outputField value="{!tec.Monday__c}" Rendered="{!IF(MONTH(tec.Monday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/> </apex:column> <apex:column width="10" headerValue="Tue"> <apex:outputField value="{!tec.Tuesday__c}" Rendered="{!IF(MONTH(tec.Tuesday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/> </apex:column> <apex:column width="10" headerValue="Wed"> <apex:outputField value="{!tec.Wednesday__c}" Rendered="{!IF(MONTH(tec.Wednesday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/> </apex:column> <apex:column width="10" headerValue="Thu"> <apex:outputField value="{!tec.Thursday__c}" Rendered="{!IF(MONTH(tec.Thursday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/> </apex:column> <apex:column width="10" headerValue="Fri"> <apex:outputField value="{!tec.Friday__c}" Rendered="{!IF(MONTH(tec.Friday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/> </apex:column> <apex:column width="10" headerValue="Sat"> <apex:outputField value="{!tec.Saturday__c}" Rendered="{!IF(MONTH(tec.Saturday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/> </apex:column> <apex:column width="10" headerValue="Sun"> <apex:outputField value="{!tec.Sunday__c}" Rendered="{!IF(MONTH(tec.Sunday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/> </apex:column> <apex:column width="10" value="{!tec.subtotal__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Itterate over your hours object, and build the map up storing the sum of hours for that day in the value. each day is a list entry.
My table has a field for each day Monday through Sunday. Would I create a List for each day as my VF page I would like a sub-total at the bottom for each day. You have helped me out a lot and I think you're familiar with my controller code by now ;) Here it is again (I renamed it since the name was not very tellilng of the controller).