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

Custom Setting Creation in Apex Test Class

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

Salesforce Trace Log Query Using Apex

AJAX Toolkit Debug Shell

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

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

Prefix List Of Salesforce Object

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

Creating Salesforce Developer Account

Recurring Scheduling Apex Job for every 10,15 etc minutes