• Anji P 9
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 5
    Replies
apex code:--

public class Pagination_Example {
    public Apexpages.StandardSetController controller {set;get;}
    public List<Opportunity> getOptyList(){
        List<Opportunity> opty=(List<Opportunity>)controller.getRecords();
        return opty;
    }
    public Pagination_Example (){
       List<opportunity> opps=[select id,name,stagename,amount from opportunity];
      controller=new apexpages.standardsetcontroller(opps);
        controller.setpagesize(10);
    }
    
}

vf page:--

<apex:page controller="Pagination_Example">
    <apex:form >
       <apex:pageblock id="pb">
        <apex:pageblockbuttons location="top">
        <apex:commandButton value="Previous" action="{!controller.previous}" rendered="{!controller.hasprevious}"/>
        <apex:commandButton value="First" action="{!controller.first}" rendered="{!controller.hasprevious}"/>
        <apex:commandButton value="Next" action="{!controller.Next}" rendered="{!controller.hasnext}"/>
        <apex:commandButton value="Last" action="{!controller.last}" rendered="{!controller.hasnext}"/>
        </apex:pageblockbuttons>
           <apex:pageBlockTable value="{!optylist}" var="a">
               <apex:column value="{!a.name}"/>
               <apex:column value="{!a.stagename}"/>
               <apex:column value="{!a.amount}"/>
           </apex:pageBlockTable>
           <apex:facet name="footer"> <h1>
            {!controller.pagenumber}&nbsp;&nbsp;of&nbsp;&nbsp;{!controller.resultsize}
         
               </h1>
           </apex:facet>
           </apex:pageblock>
    </apex:form>
</apex:page>