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}"/>
<apex:commandLink action="{!Next}" value="Next Page" rendered="{!HasNext}"/>
<apex:commandLink action="{!Last}" value="Last Page" rendered="{!HasNext}"/>
<apex:commandLink action="{!First}" value="First Page" rendered="{!HasPrevious}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
---------------------------------------------
I hope this will help you.
-----------------------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}"/>
<apex:commandLink action="{!Next}" value="Next Page" rendered="{!HasNext}"/>
<apex:commandLink action="{!Last}" value="Last Page" rendered="{!HasNext}"/>
<apex:commandLink action="{!First}" value="First Page" rendered="{!HasPrevious}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
---------------------------------------------
I hope this will help you.
Comments
Post a Comment