You need to sign in to do that
Don't have an account?
Adam Balme 13
Display live sum of of currency field of selected records
I have a VF page that displays a live count of selected rows of a VF page. I'd like to also show a sum of a currency field for the selected records. Let's say the field is Total_Amount__c.
How could I include this live sum in my page.
here is the code:
How could I include this live sum in my page.
here is the code:
Vf page: <apex:page controller="CountLiveController"> <script> function test() { console.log('>>yes'); methodOneInJavascript(); } </script> <apex:form id="frm" > <apex:actionFunction action="{!methodOne}" name="methodOneInJavascript" rerender="frm"/> <apex:pageBlock title="Accounts"> <apex:pageBlockTable value="{!wrapList}" var="a"> <apex:column headerValue="Select Account"> <apex:inputCheckbox value="{!a.selected}" onchange="test();"/> </apex:column> <apex:column headervalue="Account Name" value="{!a.acc.name}"/> </apex:pageBlockTable> <apex:pageBlockSection> Live Count::: {!Count} </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>Controller:
public class CountLiveController { public List<Account> acList{get;set;} public List<AccountWrapper> wrapList{get;set;} public List<AccountWrapper> selectedWrap{get;set;} public Integer Count{get;set;} public CountLiveController() { acList=new List<Account>(); selectedWrap = new List<AccountWrapper>(); acList=[Select name from Account limit 10];// Show number of accounts as per requirement wrapList=new List<AccountWrapper>(); for(Account a:acList) { AccountWrapper aw=new AccountWrapper(a); wrapList.add(aw); } System.debug('>>wrapList'+wrapList); } public class AccountWrapper{ public Boolean selected{get;set;} public Account acc{get;set;} public AccountWrapper(Account a) { acc=a; selected=false; } } public void methodOne() { selectedWrap.clear(); for(AccountWrapper wrap:wrapList) { if(wrap.selected==true) { selectedWrap.add(wrap); } Count=selectedWrap.size(); system.debug('::::'+selectedWrap); } } }
Hi Adam Balme,
If you found it useful please appreciate my efforts and mark it as the best answer.
LinkedIn: https://www.linkedin.com/in/soyab-hussain-b380b1194/
Regards
Soyab
All Answers
Hi Adam Balme,
If you found it useful please appreciate my efforts and mark it as the best answer.
LinkedIn: https://www.linkedin.com/in/soyab-hussain-b380b1194/
Regards
Soyab