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);
}
}