i want to update Result field = True for Selected(Check box =true) records in CampaignMember once i click on Approve Button in page. Please help on this
Page:
<apex:pageBlockButtons >
<apex:commandButton value="Approve" action="{!Approve}"/>
<apex:commandButton value="Reject"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!CampaignMember}" var="a" id="opp_table">
<apex:column >
<apex:facet name="header" > <apex:inputCheckbox title="" > SELECT ALL
<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" rerender="Selected_PBS"/>
</apex:inputCheckbox>
</apex:facet>
<apex:inputCheckbox value="{!a.selected}" id="checkedone">
<apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_PBS"/></apex:inputCheckbox>
</apex:column>
<apex:column headervalue="CampaignName" value="{!a.acc.Campaign.Name}" />
<apex:column headervalue="MemberName" value="{!a.acc.Contact.LastName}" />
<apex:column headervalue="Approval_by_Campaign_Admin" value="{!a.acc.Approval_by_Campaign_Admin__c}" />
<apex:column headervalue="Result" value="{!a.acc.Result__c}" />
</apex:pageBlockTable>
<apex:panelGrid columns="2">
<apex:commandLink action="{!previous}">Previous</apex:commandlink>
<apex:commandLink action="{!next}">Next</apex:commandlink>
</apex:panelGrid>
</apex:pageBlock>
function checkAll(cb) { var inputElem = document.getElementsByTagName("input"); for(var i=0; i
Controller :
public class Checkbox_Member {
public PageReference Approve() {
return null;
}
List<accountwrapper> accountList = new List<accountwrapper>();
List<campaignMember> selectedAccounts = new List<campaignMember>();
public PageReference getSelected()
{
selectedAccounts.clear();
for(accountwrapper accwrapper : accountList)
if(accwrapper.selected == true)
selectedAccounts.add(accwrapper.acc);
return null;
}
public List<accountwrapper> getCampaignMember()
{
for(campaignMember a : [select id,Campaign.Name,Contact.LastName,Approval_by_Campaign_Admin__c,Result__c,Action__c from campaignMember])
accountList.add(new accountwrapper(a));
return accountList;
}
public class accountwrapper
{
public campaignMember acc{get; set;}
public Boolean selected {get; set;}
public accountwrapper(campaignMember a)
{
acc = a;
selected = false;
}
}
public PageReference next() {
return null;
}
public PageReference previous() {
return null;
}
}