function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Devaraj 7Devaraj 7 

pagination with example if i want to work with standardsetcontroller any sample example please provide me.

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Devaraj,

Pagination using standard set controller  May I request you please refer the below link for reference. Hope it will be helpful.

Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.

Thanks
Rahul Kumar
Ajay K DubediAjay K Dubedi

Hi Devaraj,
Below is the code for the same. It working fine in my Org. I have used it for Standard object Contact.

Visualforce Page:-
<apex:page standardController="Contact" recordSetVar="contacts">
    <apex:form >
        <apex:pageBlock title="Contact List" id="contacts_list">
            Filter: 
            <apex:selectList value="{! filterId }" size="1">
                <apex:selectOptions value="{! listViewOptions }"/>
                <apex:actionSupport event="onchange" reRender="contacts_list"/>
            </apex:selectList>
            <apex:pageBlockTable title="Contacts" value="{!contacts}" var="c">
                <apex:column value="{!c.Name}" />
                <apex:column value="{!c.Email}" />
                <apex:column value="{!c.Account.Name}" />
            </apex:pageBlockTable>
            <table style="width:100%">
                <td align="left"><apex:outputText >Page {! PageNumber } of {! CEILING(ResultSize/PageSize) }</apex:outputText></td>
                <td align="center">
                    <apex:commandLink action="{! previous }" value="« Previous" rendered="{! hasPrevious }" />
                    <apex:outputText style="color:#ccc" value="« Previous" rendered="{! NOT(hasPrevious) }" />
                    &nbsp;
                    <apex:commandLink action="{! next }" value="Next »" rendered="{! hasNext }" />
                    <apex:outputText style="color:#ccc" value="Next »" rendered="{! NOT(hasNext) }" />
                </td>
                <td align="right">
                    Records per page:
                    <apex:selectList value="{! PageSize }" size="1">
                        <apex:selectOption itemValue="5" itemLabel="5" />
                        <apex:selectOption itemValue="10" itemLabel="10" />
                        <apex:selectOption itemValue="20" itemLabel="20" />
                        <apex:actionSupport event="onchange" reRender="contacts_list" />
                    </apex:selectList>
                </td>
            </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Screenshot:-

User-added image

Regard,
Ajay

DoondiDoondi
@ajay, It worked great for me too, Thanks a lot :-)
Deepali KulshresthaDeepali Kulshrestha
Hi Devaraj,

Pagination is the process of displaying a large number of records and displaying the records on multiple pages within in Salesforce
You can change this page according to your requirement.
 
<apex:page standardController="Opportunity" extensions="oppoNe" recordSetVar="opportunities">
<apex:pageBlock title="Viewing Opportunities">
<apex:form id="theForm">
<apex:pageBlockSection >
<apex:dataList var="opp" value="{!opportunities}">
{!opp.Name}
</apex:dataList>
</apex:pageBlockSection>
<apex:panelGrid columns="4">
<apex:commandLink action="{!first}">FIRST</apex:commandLink>
<apex:commandLink action="{!next}">NEXT</apex:commandLink>
<apex:commandLink action="{!previous}">PREVIOUS</apex:commandLink>
<apex:commandLink action="{!last}">LAST</apex:commandLink>
</apex:panelGrid>
 
</apex:form>
</apex:pageBlock>
</apex:page>

Controller:

public class oppoNe {
 
    public oppoNe(ApexPages.StandardSetController controller) {
        controller.setPageSize(10);
    }
 
}
I suggest you visit this link, it will help you 

https://mytutorialrack.com/how-to-implement-pagination-in-visualforce-with-example/
http://amitsalesforce.blogspot.com/2015/04/pagination-using-standardsetcontroller.html


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha.
Tyler McCartyTyler McCarty
@Deepali But how would you set page size in a custom controller?