You need to sign in to do that
Don't have an account?
Pagination Not Working Properly.. I Need Help!!!.
When i search record by name or i change the pagesize or i try to delete a record by clicking the delete link no controller action gets called.
vf Page ======================= <apex:page controller="pagination" docType="html-5.0"> <apex:form > search opportunity by name: <apex:inputText value="{!searchByString}"> <apex:actionSupport event="onchange" action="{!searchOpportunity}" reRender="Display"/> </apex:inputText> opportunities per page: <apex:input value="{!size}" type="number" id="number_of_days" html-step="10" html-min="10" html-max="100"> <apex:actionSupport event="onchange" action="{!afterSizePageChange}" reRender="Display"/> </apex:input> <apex:sectionHeader title="Pagination"/> <apex:pageBlock id="Display" > <apex:inlineEditSupport /> <apex:pageBlockButtons > <apex:commandButton value="First" action="{!controller.first}" rendered="{!controller.hasprevious}" reRender="Display"/> <apex:commandButton value="Previous" action="{!controller.previous}" rendered="{!controller.hasprevious}" reRender="Display"/> <apex:commandButton value="Next" action="{!controller.next}" rendered="{!controller.hasnext}" reRender="Display"/> <apex:commandButton value="Last" action="{!controller.last}" rendered="{!controller.hasnext}" reRender="Display"/> </apex:pageBlockButtons> <!-- if there is no record than show a message --> <apex:outputText rendered="{!IF(wrapperRecordList.size==0,'true','false')}">No Record Found </apex:outputText> <apex:pageBlockTable value="{!wrapperRecordList}" var="a" rendered="{!IF(wrapperRecordList.size>0,'true','false')}"> <apex:column > <apex:facet name="header"><apex:selectCheckboxes /></apex:facet> <apex:selectCheckboxes value="{!a.isSelected}"/> </apex:column> <apex:column headervalue="Action"> <apex:commandLink value="Delete" action="{!deleteRecord}" reRender="Display"> <apex:param value="{!a.oppRecord.id}" assignTo="{!id}" /> </apex:commandLink> </apex:column> <apex:column value="{!a.oppRecord.name}"/> <apex:column value="{!a.oppRecord.stagename}"/> <apex:column value="{!a.oppRecord.closeDate}"/> </apex:pageBlockTable><br/><br/> <apex:outputText rendered="{!IF(wrapperRecordList.size>0,'true','false')}">{!(controller.pageNumber * size)+1-size}-{!IF((controller.pageNumber * size)>controller.resultsize, controller.resultsize,(controller.pageNumber * size))} of {!controller.resultsize}</apex:outputText> </apex:pageBlock> </apex:form> </apex:page>
public class pagination { public ApexPages.StandardSetController controller {set;get;} public string searchByString {set;get;} public Integer size {set;get;} public string id {set;get;} public List<opportunity> optyList {set;get;} public List<WrapperClass> wrapperRecordList {set;get;} public pagination(){ size=10; wrapperRecordList=new List<WrapperClass>(); optyList=[select name,stagename,closeDate from opportunity order by name ASC]; controller=new Apexpages.StandardSetController(optyList); controller.setPageSize(size); List<opportunity> opty=(List<Opportunity>)controller.getRecords(); for(opportunity op:opty) { wrapperRecordList.add(new WrapperClass(op, false)); } } public void afterSizePageChange() { optyList=[select name,stagename,closeDate from Opportunity order by name ASC]; controller=new Apexpages.StandardSetController(optyList); controller.setPageSize(size); List<opportunity> opty=(List<Opportunity>)controller.getRecords(); for(opportunity op:opty) { wrapperRecordList.add(new WrapperClass(op, false)); } } public void searchOpportunity() { string name=searchByString+'%'; optylist=[select name,stagename,closeDate from Opportunity where name like : name order by name ASC]; controller=new Apexpages.StandardSetController(optyList); controller.setPageSize(size); List<opportunity> opty=(List<Opportunity>)controller.getRecords(); for(opportunity op:opty) { wrapperRecordList.add(new WrapperClass(op, false)); } } public void deleteRecord() { list<opportunity> opp =[select id,name from opportunity where id =:id]; delete opp; optyList=[select name,stagename,closeDate from Opportunity order by name ASC];
Can you explain breifly about your requirement
Will you need the coding for the search record by name and change the pagesize and delete a record by clicking the delete link
Thanks
Jenefa
Sweet Potato Tec
Hi,Soma
pls review the code
like when i search a record by any string or click on delete link no method of controller gets called.
if you have code for the same functionality then pls send
Here below is the controller class for above vf page