You need to sign in to do that
Don't have an account?
Deepak Chouhan 9
Select Wrapper class records when click on Checkbox
I am trying to write a wrapper class for contact with pagination. when i click on checkbox. records are not selecting. can u help me out.
public List contactListWrapper{get;set;}
public Boolean allContact {get;set;}
public Pattern nonAlphanumeric = Pattern.compile('[^a-zA-Z0-9 -]');
public List getContactRecords(){
String qryStrContact = 'Select ID,Name,Email from Contact where Email !=null AND ID NOT IN (SELECT Book_Contact__c FROM Book__c WHERE Book_Subscription_of_Contact__c=TRUE AND Book_Contact__c !=NULL ) ORDER By Name ';
qryStrContact+= ' limit :limitSize offset :offsetSize';
contactListWrapper = new List();
List listContact = Database.Query(qryStrContact);
if(listContact.size() > 0) {
for(Contact c : listContact){
if(!nonAlphanumeric.matcher(c.Name).find())
contactListWrapper.add(new contactWrapperClass(c));
}
}else{ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'No records found!')); } return contactListWrapper; }
//method for select all contact records public void selectAllContact() { if(allContact) { for(contactWrapperClass w : contactListWrapper) { w.checked = true; } } else { for(contactWrapperClass w : contactListWrapper) { w.checked = false; } } }
//----- Contact Wrapper Class public class contactWrapperClass { public Boolean checked {get;set;} public Contact con{get;set;} public contactWrapperClass(Contact con) { this.con= con; } }
public List contactListWrapper{get;set;}
public Boolean allContact {get;set;}
public Pattern nonAlphanumeric = Pattern.compile('[^a-zA-Z0-9 -]');
public List getContactRecords(){
String qryStrContact = 'Select ID,Name,Email from Contact where Email !=null AND ID NOT IN (SELECT Book_Contact__c FROM Book__c WHERE Book_Subscription_of_Contact__c=TRUE AND Book_Contact__c !=NULL ) ORDER By Name ';
qryStrContact+= ' limit :limitSize offset :offsetSize';
contactListWrapper = new List();
List listContact = Database.Query(qryStrContact);
if(listContact.size() > 0) {
for(Contact c : listContact){
if(!nonAlphanumeric.matcher(c.Name).find())
contactListWrapper.add(new contactWrapperClass(c));
}
}else{ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'No records found!')); } return contactListWrapper; }
//method for select all contact records public void selectAllContact() { if(allContact) { for(contactWrapperClass w : contactListWrapper) { w.checked = true; } } else { for(contactWrapperClass w : contactListWrapper) { w.checked = false; } } }
//----- Contact Wrapper Class public class contactWrapperClass { public Boolean checked {get;set;} public Contact con{get;set;} public contactWrapperClass(Contact con) { this.con= con; } }
Please find the below link, it will help you to hlod the selected wrapper record,
http://salesforcehelpinghands.blogspot.in/2012/10/pagination-with-maintaing-state-of.html
Please let me know, if it is helpfull,
Best Regards,
Dayakar.D
1) http://amitsalesforce.blogspot.com/2016/03/wrapper-class-in-salesforce-select-all.html
Pagination with Wrapper Class ( with maintaing the state of selected records)
1) http://amitsalesforce.blogspot.com/2014/11/pagination-with-wrapper-class-with.html