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
Cloud_DragonCloud_Dragon 

Need Help on Pagination:

Hi,

 

I have been working on pagination on my vf page. The issue i am stuck right now is , though i click the next button the page doesnt gets to the next set of records. It only shows the initial set of records i set by setPageSize.

 

Not sure what i am missing . please help.

 

VF Code:

<apex:page controller="setTestController">
<apex:form>

<apex:dataTable value="{!RetirieveProducts}" var="products" styleClass="list" id="productsLstTable" rules="rows">
<apex:column >
                  <apex:facet name="header"><b>Product Name</b></apex:facet>
                  <apex:outputText value="{!products.name}"/>
               </apex:column>

</apex:datatable>
<apex:panelGrid columns="4" id="pnlGrid">
    <apex:commandLink action="{!con.next}" rendered="{!con.hasNext}">Next</apex:commandlink>
    </apex:panelGrid>

</apex:form>
</apex:page>

 

Controller:

public class setTestController{
public ApexPages.StandardSetController con{get; set;}
public string soql{get;set;}
public List<product2> RetirieveProducts{get;set;}
public void paginationMethod(){
 soql='select id,name from product2 where Id != null and Third_Party_Vendor__c = null';
 con = new ApexPages.StandardSetController(Database.getQueryLocator(soql));
 con.setPageSize(5);
 for(Product2 p : (List<Product2>)con.getRecords())
         {
           RetirieveProducts.add(p);
           //lstProducts.add(new ProductWrapper(p));
         }
}
public setTestController(){
 RetirieveProducts=new List<Product2>();

paginationMethod();

}

 public Boolean getHasNext {
        get {
            return con.getHasNext();
        }
     }

 public void next() {
        con.next();
    }


}