function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Deepak Chouhan 9Deepak 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; } }
Dayakar.DDayakar.D
Hi Deepak,

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
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for wrapper class
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