Activity Forums Salesforce® Discussions Pagination in salesforce

  • Pagination in salesforce

    Posted by Piyush on September 17, 2019 at 4:39 am

    I’m trying to implement Pagination. Initially i want to display 50 records and when user click on Next button, the records stating from 51 to 100 should get displayed. How do I accomplish this.

    Hariom Chaudhary replied 5 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Hariom Chaudhary

    Member
    September 17, 2019 at 9:50 am

    Pagination is the process of displaying large number of records and displaying the records on multiple pages within in Salesforce. By default, a list controller returns 20 records on the page.

    To customize it, we can use a controller extension to set the pageSize. Take a look at the sample code below:

    <apex:page standardController="Opportunity" extensions="opp" recordSetVar="opportunities">
    <apex:pageBlock title="Viewing Opportunities">
    <apex:form id="theForm">
    <apex:pageBlockSection >
    <apex:dataList var="opp" value="{!opportunities}">
    {!opp.Name}
    </apex:dataList>
    </apex:pageBlockSection>
    <apex:panelGrid columns="4">
    <apex:commandLink action="{!first}">FIRST</apex:commandLink>
    <apex:commandLink action="{!next}">NEXT</apex:commandLink>
    <apex:commandLink action="{!previous}">PREVIOUS</apex:commandLink>
    <apex:commandLink action="{!last}">LAST</apex:commandLink>
    </apex:panelGrid>

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

    Apex Class:

    public class opp{

    public opp(ApexPages.StandardSetController controller) {
    controller.setPageSize(10);
    }

    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos