Custom Pagination Without Controller (Apex)

You can see the use below VF code without any controller to get paginated records of any Standard object /Custom object..
-----------------------VF Code Without Controller--------------------
<apex:page standardController="Account" recordSetVar="accounts" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Return" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!accounts}" var="s" id="table" rows="20">
<apex:column headerValue="Account Name">
<apex:outputField value="{!s.Name}"/>
</apex:column>
</apex:pageBlockTable>

<!-- To See the below link(Next,Previous,First,Last), You must have more than 20 records otherwise you won't see the pagination effect-->
<apex:commandLink action="{!Previous}" value="Previous Page" rendered="{!HasPrevious}"/>&nbsp;
<apex:commandLink action="{!Next}" value="Next Page" rendered="{!HasNext}"/>&nbsp;
<apex:commandLink action="{!Last}" value="Last Page" rendered="{!HasNext}"/>&nbsp;
<apex:commandLink action="{!First}" value="First Page" rendered="{!HasPrevious}"/>
</apex:pageBlock>
</apex:form>
</apex:page>

---------------------------------------------

I hope this will help you.

Comments

Popular posts from this blog

System.AsyncException: The Apex job named is already scheduled for execution.

Custom Setting Creation in Apex Test Class

Error : "Trigger must be associated with a job detail"

AJAX Toolkit Debug Shell

Salesforce Trace Log Query Using Apex

how to get object name from id / prefix value in salesforce

How to Query All the batch classes in your Salesforce Instance using APEX

Creating Salesforce Developer Account

Creating MAP from SOQL Query