You need to sign in to do that
Don't have an account?
Anji P 9
{!controller.pagenumber} of {!controller.resultsize} i'm getting o/p like 1 of 47 but i want 1-10 of 47
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} of {!controller.resultsize}
</h1>
</apex:facet>
</apex:pageblock>
</apex:form>
</apex:page>
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} of {!controller.resultsize}
</h1>
</apex:facet>
</apex:pageblock>
</apex:form>
</apex:page>
All Answers
Please use the below Code i.e small changes in your code that will work!!!
Apex Code:
public class Pagination_Example {
Public Integer resultsize{get;set;}
Public Integer size{get;set;}
public Apexpages.StandardSetController controller {set;get;}
public List<Opportunity> getOptyList(){
List<Opportunity> opty=(List<Opportunity>)controller.getRecords();
return opty;
}
public Pagination_Example (){
size=10;
List<opportunity> opps=[select id,name,stagename,amount from opportunity];
resultsize=opps.size();
controller=new apexpages.standardsetcontroller(opps);
controller.setpagesize(size);
}
}
Visualforce 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 * size)+1-size}-{!IF((controller.pageNumber * size)>resultsize, resultsize,
(controller.pageNumber * size))} of {!resultsize}
</h1>
</apex:facet>
</apex:pageblock>
</apex:form>
</apex:page>
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Raj