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
Devang Rana 6Devang Rana 6 

I need to integrate this type pagination

User-added image

If i select 5 from picklest then in page only display 5 records. and if i m select 10 from picklest then it will be display 10 records in page.

please some one give suggeation hoe can i do that?

Thanks in advance.
srlawr uksrlawr uk
Looks like you are using a standard set controller... the StandardSetController has a method called
setPageSize(Integer)

So all you need to do is assign a value to that and rerender the table.

Here is the documentation on StandardSetControllers, with that method in:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_ApexPages_StandardSetController_methods.htm

I would put an ActionFunction on the picklist (onChange) that called an Apex method (maybe call it ResizeTable()) that then took the value from the picklist, set it into setPageSize and then on the picklist have a rerender="yourTableId"

That sounds like it will do exactly what you are after :)
Rupal KumarRupal Kumar
Hi,
Use this code-
VFPage-
<apex:page controller="Pagination_minnew">
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageBlockTable value="{!Accounts}" var="a">
              <apex:column >
                    <apex:facet name="header">Action</apex:facet>
                    <apex:inputCheckbox />
                </apex:column>
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Type}"/>
                <apex:column value="{!a.BillingCity}"/>
                <apex:column value="{!a.BillingState}"/>
                <apex:column value="{!a.BillingCountry}"/>
            </apex:pageBlockTable>
            <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/>
                <apex:outputText >{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/>
                <apex:actionFunction name="show" action="{!refresh}" reRender="pb" />
                <apex:selectList value="{!size}"  multiselect="false" size="1" onchange="show()">
                      <apex:selectOptions value="{!items}"/>
                   </apex:selectList>      
                <apex:outputPanel style="color:#4AA02C;font-weight:bold">
                    <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
                </apex:outputPanel>
            </apex:panelGrid>
        </apex:pageBlock>
    </apex:form>
</apex:page>
controller-
public with sharing class Pagination_minnew {
    Public Integer noOfRecords{get; set;}
    Public Integer size{get;set;}
    public boolean test = false;
    public ApexPages.StandardSetController setCon {
        get{
            if(setCon == null){
                if(test == false){
                size = 10;
                }
                string queryString = 'Select Name, Type, BillingCity, BillingState, BillingCountry from Account order by Createddate DESC';
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();
                test = true;
            }
            return setCon;
        }set;
    }
     
    Public List<Account> getAccounts(){
        List<Account> accList = new List<Account>();
        for(Account a : (List<Account>)setCon.getRecords())
            accList.add(a);
        return accList;
    }
     
    public pageReference refresh() {
        setCon = null;
        getAccounts();
        setCon.setPageNumber(1);
        return null;
    }
    public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('10','10'));
            options.add(new SelectOption('20','20'));
            options.add(new SelectOption('30','30'));
            return options;
        }
}

Thanks
Rupal Kumar
http://mirketa.com
 
Amit Chaudhary 8Amit Chaudhary 8
If you are using standardSetController then please check below post
1)http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/
2) http://sfdcsrini.blogspot.com/2014/07/simple-visualforce-pagination-example.html
you can use setPageSize(Integer)

I hope you are looking for jquery pagination

SORTING, PAGINATION IN VISUALFORCE USING DATATABLES JQUERY PLUG-IN.
https://yoafzal.wordpress.com/2013/02/04/sorting-pagination-in-visualforce-using-datatables-jquery-plug-in/

2) http://forcesecrets.blogspot.com/2011/10/experimenting-with-sosl-for-first-time.html

Please let us know if this will help you