function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
<apex:page controller="WrapperClassExample" sidebar="false"> <apex:form > <apex:pageBlock title="Wrapperclass example" id="refer"> <apex:outputPanel id="pgrefresh"> <apex:pageBlockTable value="{!allRecords}" var="allrcs" id="Refresh"> <apex:column headerValue="S.No" value="{!allrcs.RowNo}"/> <apex:column headerValue="select"> <apex:inputCheckbox value="{!allrcs.chk}"/> </apex:column> <apex:column headerValue="Account"> <apex:inputText value="{!allrcs.acc.name}"/> </apex:column> <apex:column headerValue="Contact lastname" > <apex:inputText value="{!allrcs.con.lastname}"/> </apex:column> <apex:column headerValue="Contact firstname" > <apex:inputText value="{!allrcs.con.firstname}"/> </apex:column> </apex:pageBlockTable> </apex:outputPanel> <apex:commandButton value="Update Records" action="{!updateRecords}" rerender="pgrefresh"/> </apex:pageBlock> </apex:form> </apex:page> ================== public class WrapperClassExample { public list<innerwrapper> allRecords{get;set;} public integer RowNo{set;get;} public WrapperClassExample(){ //RowNo = 1; allRecords = new list<innerwrapper>(); list<contact> lstContacts = [select id,firstname,lastname,account.name from contact where account.name != null limit 10]; for(integer i=0;i<lstContacts.size();i++){ RowNo = i+1; innerwrapper iw = new innerwrapper(lstContacts[i].account,lstContacts[i],false,RowNo); allRecords.add(iw); } } public PageReference updateRecords(){ boolean updflag = false; PageReference curPage; if(allRecords.size()>0){ for(integer i=0;i<allRecords.size();i++){ if(allRecords[i].chk == True){ system.debug('==allRecords[i]=='+allRecords[i]); update allRecords[i].acc; system.debug('==allRecords[i].acc=='+allRecords[i].acc); update allRecords[i].con; system.debug('==allRecords[i].con=='+allRecords[i].con); updflag = true; } } } if(updflag == true){ curPage = page.WrapperClasExample; //new PageReference('/apex/Wrapperclasexample'); curPage.setRedirect(true); } return curPage; } public class innerwrapper{ public account acc{get;set;} public contact con{get;set;} public boolean chk{get;set;} public integer rowNo{get;set;} public innerwrapper(account a,contact c,boolean b,integer row){ acc = a; con = c; chk = b; rowNo = row; } } }
Please check sample code below :
Hope this helps you.
If the above information helps you Please mark it as the best answer.
Thanks
Varaprasad
All Answers
Please check sample code below :
Hope this helps you.
If the above information helps you Please mark it as the best answer.
Thanks
Varaprasad
<apex:page controller="wrapperclassv1">
<apex:form >
<apex:pageBlock >
<apex:commandButton value="show" action="{!displayselected}" reRender="s"/>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!wlist}" var="cc" >
<apex:column value="{!cc.sr}" headerValue="serial no"/>
<apex:column value="{!cc.cw.name}"/>
<apex:column headerValue="select">
<apex:inputCheckbox value="{!cc.selected}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection title="output">
<apex:pageBlockTable value="{!wlistshow}" var="cc" id="s">
<apex:column value="{!cc.sr}" headerValue="serial number"/>
<apex:column value="{!cc.cw.name}"/>
<apex:column headerValue="select">
<apex:inputCheckbox value="{!cc.selected}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public class wrapperclassv1 {
public list<account> cl{set;get;}
public list<account> clshow{set;get;}
public boolean check{set;get;}
public integer sr{set;get;}
public list<wrapinner> wlist{set;get;}
public list<wrapinner> wlistshow{set;get;}
public wrapperclassv1(){
clshow = new list<account>();
cl = [select id ,name from account limit 10 ];
for(integer i=0;i<cl.size();i++){
sr=i+1;
wlist = new list<wrapinner>();
for(account a: cl){
wlist.add(new wrapinner(a,false,sr));
}
}
}
public void displayselected(){
wlistshow = new list<wrapinner>();
for(wrapinner wi : wlist){
if(wi.selected == true){
wlistshow.add(wi); }
}
}
public class wrapinner{
public account cw{set;get;}
public boolean selected{set;get;}
public integer sr{set;get;}
public wrapinner(account cw,boolean selected,integer sr){
this.cw = cw;
this.selected= selected;
this.sr=sr;
}
}
}