Simple Pagination
Pagination - To traverse back and forth.
We have used a simple standard apex class controller, an Extension and visualforce page to achieve this task. Below is Output of the code.
Explanation - The constructor in the apex class always sets the page size to 2. You can try increasing the values for viewing more records.
Apex Class
public with sharing class PageDataClass { public PageDataClass(ApexPages.StandardSetController controller) { controller.setpagesize(2); } }
Explanation - The actions of the commandLinks work even though when there are no methods written in our extension class, wondering why ? These actions are performed by default when a standard controller is in use. (ex: save ...)
Visualforce Page
<apex:page sidebar="false" standardController="MybookSubs__c" recordSetVar="records" extensions="PageDataClass"> <apex:form > <apex:pageBlock > <apex:pageBlockSection > <apex:pageBlockTable value="{!records}" var="r"> <apex:column headerValue="Name"> {!r.Name} </apex:column> <apex:column headerValue="Author"> {!r.Author__c} </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> <apex:commandLink value="previous" action="{!previous}"/> | <apex:commandLink value="next" action="{!next}"/> </apex:pageBlock> </apex:form> </apex:page>
Simple Pagination
Reviewed by dasfrogpractice
on
01:42
Rating:
No comments: