+ Start a Discussion
sfdc_dev123sfdc_dev123 

Pagination with page numbers in vf page

Hi,

 

I displayed account records with pagination Next, Previous links with page limit 20 records.

In my account have 200 records. My requirement is 

Previous 1 2 3 4 5 Next

 

First time Page no1 is highlet and clicking on next button current pages only highlets

Can you please any body help me.

 

 

 

Thank you

Devendra@SFDCDevendra@SFDC

Hi,

 

You can refer following Blog

 

Thanks,

Devendra

sfdc_dev123sfdc_dev123

Hi Devendra,

 

 

Thank you for reply. Is it possible to display numbers with command link.

 

 

 

Thank you

PremanathPremanath

This may helpful for you,

You can try this way you will reach

 

<apex:page controller="opportunityList2Con">
    <apex:sectionHeader Title="This is a Set Controller Test" subtitle="There are a total of {!reccount} Records in this list" title="Oppurtunity"/>
    <apex:pageBlock >
        <apex:form >
        <apex:pageBlockTable value="{!opportunities}" var="o">
            <apex:column value="{!o.name}"/>
            <apex:column value="{!o.closedate}"/>
        </apex:pageBlockTable>
        <apex:commandLink action="{!previous}">Previous</apex:commandlink> &nbsp;
    <apex:commandLink action="{!next}">Next</apex:commandlink>

        </apex:form>
    </apex:pageBlock>
</apex:page>

 

 

public class opportunityList2Con {

    public Integer getReccount() {
        return setCon.getResultSize();
    }

    
    Public void Next(){
        setCon.next();        
    }

    Public void Previous(){
        setCon.previous();
    }

    public string qry='select name,closedate from Opportunity limit 9999';
    public ApexPages.StandardSetController setCon {get {
            if(setCon == null) {setCon = new ApexPages.StandardSetController(Database.getQueryLocator(qry));
            }
            setCon.setPageSize(10);
            return setCon;
        }set;
    }
    public List<Opportunity> getOpportunities() {
         return (List<Opportunity>) setCon.getRecords();
    }
}