I was able to create pagination for my table. Now i want to add page number on the bottom of my table(like page number of Total pages ). But i kinda struggle to do that. Anybody have any idea? Thanks
VF Page:
<apex:page standardController="Product_Brief__c" extensions="DispatcherContactNewController">
<apex:pageBlock >
<apex:pageBlockTable value="{!pbs}" var="p">
<tr class="lnkdsble" ><apex:column value="{!p.Name}"/></tr>
<apex:column value="{!p.RecordTypeId}"/>
<apex:column value="{!p.Createddate}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:panelGrid columns="4">
<apex:commandLink action="{!first}">First</apex:commandlink>
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
<apex:commandLink action="{!last}">Last</apex:commandlink>
</apex:panelGrid>
</apex:pageBlock>
</apex:form>
</apex:page>
Extension
public class DispatcherContactNewController {
public DispatcherContactNewController(ApexPages.StandardController controller) {
this.controller = controller;
}
public ApexPages.StandardSetController setpb {
get{
if (setpb == null) {
setpb = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT Id, Name, RecordTypeId, Createddate FROM Product_Brief__c])
);
}
return setpb;
}
set;
}
public List<Product_Brief__c>getpbs() {
return (List<Product_Brief__c>)setpb.getrecords();
}
public Boolean hasNext {
get {
return setpb.getHasNext();
}
set;
}
public Boolean hasPrevious {
get {
return setpb.getHasPrevious();
}
set;
}
public Integer pageNumber {
get {
return setpb.getPageNumber();
}
set;
}
public void first() {
setpb.first();
}
public void last() {
setpb.last();
}
public void previous() {
setpb.previous();
}
public void next() {
setpb.next();
}
}
getPageSize()
andgetResultSize()
methods along with a little math. Where are you stuck? What have you tried? – Mark Pond Jul 1 '15 at 6:48