0 votes
in Technology by (438k points)
How can we implement pagination in Visualforce?

1 Answer

0 votes
by (438k points)

To control the number of records displayed on each page, we use pagination. 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:-

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<apex:page standardController="Account" recordSetvar="accounts">

 <apex:pageBlock title="Viewing Accounts">

 <apex:form id="theForm">

 <apex:pageBlockSection >

 <apex:dataList var="a" value="{!accounts}" type="1">

 {!a.name}

 </apex:dataList>

 </apex:pageBlockSection>

 <apex:panelGrid columns="2">

 <apex:commandLink action="{!previous}">Previous</apex:commandlink>

 <apex:commandLink action="{!next}">Next</apex:commandlink>

 </apex:panelGrid>

 </apex:form>

 </apex:pageBlock>

</apex:page>

Related questions

...