You need to sign in to do that
Don't have an account?
Pradeep d
How to maintain checkbox status while using standardsetcontroller
Am implementing records with checkboxes, during pagination process, state of checkbox is not maintaing in front end :( back end its working well, pls help ma issue.
public void init() { wrapperRecordList = new List<WrapperClass>(); system.debug(setCon.getRecords()); for (Contact cont : (List<Contact>)setCon.getRecords()) { if(mapHoldingSelectedRecords != null && mapHoldingSelectedRecords.containsKey(cont.id)){ wrapperRecordList.add(new WrapperClass(cont, false)); } else{ wrapperRecordList.add(new WrapperClass(cont, false)); } } system.debug(wrapperRecordList.size()); } public List<Contact> conlist = new List<contact>(); public string doql; /** Instantiate the StandardSetController from a query locater*/ public ApexPages.StandardSetController setCon { get { if(setCon == null) { //string soql = 'select id, lastname, name, email, phone from contact Limit :QUERY_LIMIT'; string soql = 'SELECT id,LastName,AssistantName,AssistantPhone,Birthdate,Department,Description,Email,Fax,'; soql += 'HomePhone,MailingAddress,MailingCity,MailingCountry,MailingPostalCode,MailingState,datefield__c,To_date__c,' ; soql += 'MailingStreet,MobilePhone,Name,firstname,OtherAddress,OtherCity,OtherCountry,OtherPhone,OtherPostalCode,'; soql += 'OtherState,OtherStreet,Account.Name,LastModifiedDate,Phone,Title,Mail_Sent_Date__c,' ; soql += '(SELECT Assistant_Name__c,Assistant_Phone__c,Birthdate__c,Contact__c,CreatedById,' + 'CreatedDate,Department__c,Description__c,Email__c,Fax__c,First_Name__c,Home_Phone__c,Id,IsDeleted,Mailing_City__c,' +'Mailing_Country__c,Mailing_State_Province__c,Mailing_Street__c,Mailing_Zip_Postal_Code__c,Mobile_Phone__c,Name,' +'Other_City__c,Other_Country__c,Other_Phone__c,Other_State_Province__c,Other_Street__c,Other_Zip_Postal_Code__c,' +'OwnerId,Phone__c,Title__c from Cons__r) From Contact '; doql = soql; system.debug('doql : ' + doql); setCon = new ApexPages.StandardSetController(Database.getQueryLocator(soql + ' Limit : QUERY_LIMIT' )); system.debug(setCon); } //Search(); return setCon; } set; } public void countpage(){ contactPaginationController_utility cu = new contactPaginationController_utility(); cu.fromDate = fromDate; cu.toDate = toDate; cu.lastDate30 = lastDate30 ; cu.lastDate60 = lastDate60 ; cu.lastDate90 = lastDate90 ; cu.querybat = querybat; cu.countall(); } public void Search(){ fromDate = con.datefield__c; toDate = con.To_date__c; directsend = con.schedule_check__c; lastDate30 = System.today().addDays(-30); lastDate60 = System.today().addDays(-60); lastDate90 = System.today().addDays(-90); system.debug(doql); string whereConditions = 'where '; string resultQuery = '' ; if(con.datefield__c !=null && con.To_date__c !=null){ resultQuery = doql + whereConditions + ' LastModifiedDate >= :fromDate AND LastModifiedDate <= :toDate' ; } if(Con.Last_Sent_Date__c !='--None--'){ resultQuery = getLastsentDate(Con.Last_Sent_Date__c ,resultQuery) ; // conlist = database.query(resultQuery + ' Limit : QUERY_LIMIT'); // system.debug(conlist); } if(string.isNotBlank(SelectedOption) && string.isNotBlank(selectedOperatorOption) && string.isNotBlank(enteredText)){ resultQuery = getOperatorSelection(SelectedOption,selectedOperatorOption,resultQuery,enteredText) ; } system.debug(resultQuery + ' Limit : QUERY_LIMIT'); querybat= resultQuery; if(directsend== true){ updatecheck b2 = new updatecheck(); b2.fromDate = fromDate; b2.toDate = toDate; b2.lastDate30 = lastDate30 ; b2.lastDate60 = lastDate60 ; b2.lastDate90 = lastDate90 ; b2.queryString = querybat; Database.executeBatch(b2); } else{ setCon = new ApexPages.StandardSetController(Database.getQueryLocator(resultQuery + ' Limit : QUERY_LIMIT' )); system.debug(setCon.getRecords()); setCon.setPageSize(PAGE_SIZE); init(); } system.debug(setCon); } public Boolean hasNext { get { return setCon.getHasNext(); } set; } /** indicates whether there are more records before the current page set.*/ public Boolean hasPrevious { get { return setCon.getHasPrevious(); } set; } /** returns the page number of the current page set*/ public Integer pageNumber { get { return setCon.getPageNumber(); } set; } /** return total number of pages for page set*/ Public Integer getTotalPages(){ Decimal totalSize = setCon.getResultSize(); Decimal pageSize = setCon.getPageSize(); Decimal pages = totalSize/pageSize; return (Integer)pages.round(System.RoundingMode.CEILING); } /** returns the first page of the page set*/ public void first() { selectmethod(); // updateSearchItemsMap(); setCon.first(); init(); } /** returns the last page of the page set*/ public void last() { selectmethod(); // updateSearchItemsMap(); setCon.last(); init(); } /** returns the previous page of the page set*/ public void previous() { selectmethod(); // updateSearchItemsMap(); setCon.previous(); init(); } /** returns the next page of the page set*/ public void next() { selectmethod(); // updateSearchItemsMap(); setCon.next(); init(); } public void selectmethod() { system.debug('wrapper size :' + wrapperRecordList); if(!wrapperRecordList.isEmpty()) for(WrapperClass wrp : wrapperRecordList){ paginationmap.put(wrp.contactRecord.id, wrp); if(wrp.isSelected ){ mapHoldingSelectedRecords.put(wrp.contactRecord.id, wrp); } if(wrp.isSelected == false && mapHoldingSelectedRecords.containsKey(wrp.contactRecord.id)){ mapHoldingSelectedRecords.remove(wrp.contactRecord.id); } } system.debug(mapHoldingSelectedRecords.size()); }