You need to sign in to do that
Don't have an account?
acrozier
Adding cell values for a sum
Hello,
I need to do some calculations on cells in a datatable to generate sums, for instance, I have a QTY field and a Honoraria field. I need to mutiply the value of the Honoraria field by the QTY field to give me my Total. How can I do this in either Javascript or Apex? Code examples below,
DataTable
<apex:dataTable id="incentives" cellpadding="4px" width="100%" frame="none" border="1" Value="{!Incents}" Var="I"> <apex:column width="20%"> <apex:outputField value="{!I.QTY__c}"/> </apex:column> <apex:column width="60%"> <apex:outputField value="{!I.Description__c}"/> </apex:column> <apex:column width="20%"> <apex:outputField value="{!I.Honoraria__c}"/> </apex:column> </apex:dataTable>
Extension
public with sharing class Incent { public list<AIIncentive__c> Incents {get; set;} public list<job__c> job {get; set;} public id jobid; public string NewIncentive {get; set;} public PageReference refresh = ApexPages.currentPage(); public Incent(ApexPages.StandardController controller) { jobid = apexpages.currentpage().getParameters().get('id'); system.debug('################################## Id'+jobid); Incents = [Select QTY__c, Description__c, Honoraria__c, Job__c, Deleted__c From AIIncentive__c where Job__c = :jobid]; job = [SELECT Account__c FROM Job__c WHERE id= :jobid]; } public PageReference NewIncentive(){ AIIncentive__c obj = new AIIncentive__c(); obj.QTY__c = 0; obj.Description__c = ''; obj.Honoraria__c = 0; obj.Job__c = jobid; update Incents; insert obj; refresh.setRedirect(true); return refresh; } public PageReference save() { update Incents; refresh.setRedirect(true); return refresh; } // public PageReference SaveReturn() { // update Incents; // return // } }
If per record, you will have to create a wrapper class....
any help or examples on creating the wrapper class?
Sure...
Assume the object is Survey:
Then to use in your VF page, you would use it just like any class.....
I see this would apply it to the entire object, what syntax would I use to apply this to an SOQL query that brings up related data from the object? Below is the code I am using for this query, I am assuming I could ad dthe wrapper method to this extension?
Sorry, I forgot to mention the Incents variable is the SOQL I am using to pull up related objects.