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
VSK98VSK98 

How to display morethan 1000 rows in a custom list view in vf page

Hi All,

Please give me idea ..........How to display  morethan 1000 rows in a vf page......

I am getting below error "limit is exceed to display morethan 1000 rows", if i shows morethan 1000 rows...Even i used readonly = true in page component

Adv Thnx
Siv
 
Best Answer chosen by VSK98
suresh sanneboina 4suresh sanneboina 4
using StandardSetController we can achive this

Please find the below code

This will dispaly 200 records in the pageblock.
 
<apex:page standardController="Account" extensions="DemoController" action="{!refreshList}" title="Firm" cache="true">
<apex:form id="form">
    <apex:pageBlock id="block">
        <apex:actionStatus id="stat">
            <apex:facet name="start"> 
                    <apex:outputPanel layout="block">
                        <apex:panelGrid columns="2" style="margin:260px;">
                                <apex:panelGroup >
                                <apex:image value="/img/loading.gif" title="Processing..." style="vertical-align:middle;" />
                            </apex:panelGroup>
                            <apex:panelGroup >
                                    <div class="messageText">Loading...</div>
                            </apex:panelGroup> 
                        </apex:panelGrid>
                </apex:outputPanel>
            </apex:facet>

            <apex:facet name="stop"> 
                <apex:outputPanel styleClass="tableContainer" layout="block">   
                    <apex:pageBlockTable value="{!CurrentList}" var="a" styleclass="floatingHeaderTable">
                        <apex:column headerValue="Name" value="{!a.Name}"/>
                        <apex:column headerValue="BillingCity" value="{!a.BillingCity}"/> 
                        <apex:column headerValue="BillingState/Province" value="{!a.BillingState}"/>
                    </apex:pageBlockTable>
                     <apex:outputText value="No records to display" escape="false" rendered="{!(CurrentList.size == 0)}"/>
                </apex:outputPanel>
            </apex:facet>
        </apex:actionStatus>
        <apex:panelGrid columns="4" width="100%" columnClasses="colClass">
            <apex:outputText value="" style="float:right;width:40%" />
            <apex:panelGrid columns="4">
                <apex:commandButton status="stat" reRender="block" value="<<" action="{!standardsetcon.first}" disabled="{!!standardsetcon.hasPrevious}" style="border:none;"/>
                <apex:commandButton status="stat" reRender="block" value="Previous" action="{!standardsetcon.Previous}" disabled="{!!standardsetcon.hasPrevious}" style="border:none;"/>
                <apex:commandButton status="stat" reRender="block" value="Next" action="{!Next}" disabled="{!!standardsetcon.hasNext}" style="border:none;"/>
                <apex:commandButton status="stat" reRender="block" value=">>" action="{!standardsetcon.last}" disabled="{!!standardsetcon.hasNext}" style="border:none;" />
            </apex:panelGrid>
            <apex:outputText value="Page" style="float:right;"/>
            <apex:outputText value="{!standardsetcon.PageNumber}"/>
        </apex:panelGrid>

    </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class DemoController {

    
    private static List<Account> accountSetList{get; set;}
    
    public ApexPages.StandardSetController standardSetCon {get;set;}
    
    private static string accountListQuery;

    //Constructor
    public DemoController(ApexPages.StandardController stdcontroller) {
        
        
    }
    

    
    //Method used in all the pages(List,View,Search) table
    public List<Account> getCurrentList() {
        accountSetList = new List<Account>();    
            if(standardSetCon !=null){
                for (Account account : (List<Account>)standardSetCon.getRecords()){        
                        accountSetList.add(account );
                }
            }
        return accountSetList;
    } 
    
    //This Method used in VF_FirmList page
     public PageReference refreshList() {      
            accountListQuery= 'Select Id,Name,BillingCity,BillingState from  Account';       
            standardSetCon = new ApexPages.StandardSetController(Database.getQueryLocator(accountListQuery));
            standardSetCon.setPageSize(200);
            return null; 
    }

    Public Boolean HasNext{ get{ return standardSetCon.getHasNext();} set; }
    Public Boolean HasPrevious{ get{ return standardSetCon.getHasPrevious();}set;}
    Public Void First() { standardSetCon.First(); }
    Public Void Last(){ standardSetCon.Last(); }
    Public Void Previous(){ standardSetCon.Previous(); }
    Public Void Next(){
        standardSetCon.Next(); }

}

 

All Answers

Vijay NagarathinamVijay Nagarathinam
Hi,

You can acheive your requirement using recordsetVar in your visualforce page. Refer the below link you get some idea.

http://www.infallibletechie.com/2012/10/recordsetvar.html

Thanks,
Vijay
suresh sanneboina 4suresh sanneboina 4
using StandardSetController we can achive this

Please find the below code

This will dispaly 200 records in the pageblock.
 
<apex:page standardController="Account" extensions="DemoController" action="{!refreshList}" title="Firm" cache="true">
<apex:form id="form">
    <apex:pageBlock id="block">
        <apex:actionStatus id="stat">
            <apex:facet name="start"> 
                    <apex:outputPanel layout="block">
                        <apex:panelGrid columns="2" style="margin:260px;">
                                <apex:panelGroup >
                                <apex:image value="/img/loading.gif" title="Processing..." style="vertical-align:middle;" />
                            </apex:panelGroup>
                            <apex:panelGroup >
                                    <div class="messageText">Loading...</div>
                            </apex:panelGroup> 
                        </apex:panelGrid>
                </apex:outputPanel>
            </apex:facet>

            <apex:facet name="stop"> 
                <apex:outputPanel styleClass="tableContainer" layout="block">   
                    <apex:pageBlockTable value="{!CurrentList}" var="a" styleclass="floatingHeaderTable">
                        <apex:column headerValue="Name" value="{!a.Name}"/>
                        <apex:column headerValue="BillingCity" value="{!a.BillingCity}"/> 
                        <apex:column headerValue="BillingState/Province" value="{!a.BillingState}"/>
                    </apex:pageBlockTable>
                     <apex:outputText value="No records to display" escape="false" rendered="{!(CurrentList.size == 0)}"/>
                </apex:outputPanel>
            </apex:facet>
        </apex:actionStatus>
        <apex:panelGrid columns="4" width="100%" columnClasses="colClass">
            <apex:outputText value="" style="float:right;width:40%" />
            <apex:panelGrid columns="4">
                <apex:commandButton status="stat" reRender="block" value="<<" action="{!standardsetcon.first}" disabled="{!!standardsetcon.hasPrevious}" style="border:none;"/>
                <apex:commandButton status="stat" reRender="block" value="Previous" action="{!standardsetcon.Previous}" disabled="{!!standardsetcon.hasPrevious}" style="border:none;"/>
                <apex:commandButton status="stat" reRender="block" value="Next" action="{!Next}" disabled="{!!standardsetcon.hasNext}" style="border:none;"/>
                <apex:commandButton status="stat" reRender="block" value=">>" action="{!standardsetcon.last}" disabled="{!!standardsetcon.hasNext}" style="border:none;" />
            </apex:panelGrid>
            <apex:outputText value="Page" style="float:right;"/>
            <apex:outputText value="{!standardsetcon.PageNumber}"/>
        </apex:panelGrid>

    </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class DemoController {

    
    private static List<Account> accountSetList{get; set;}
    
    public ApexPages.StandardSetController standardSetCon {get;set;}
    
    private static string accountListQuery;

    //Constructor
    public DemoController(ApexPages.StandardController stdcontroller) {
        
        
    }
    

    
    //Method used in all the pages(List,View,Search) table
    public List<Account> getCurrentList() {
        accountSetList = new List<Account>();    
            if(standardSetCon !=null){
                for (Account account : (List<Account>)standardSetCon.getRecords()){        
                        accountSetList.add(account );
                }
            }
        return accountSetList;
    } 
    
    //This Method used in VF_FirmList page
     public PageReference refreshList() {      
            accountListQuery= 'Select Id,Name,BillingCity,BillingState from  Account';       
            standardSetCon = new ApexPages.StandardSetController(Database.getQueryLocator(accountListQuery));
            standardSetCon.setPageSize(200);
            return null; 
    }

    Public Boolean HasNext{ get{ return standardSetCon.getHasNext();} set; }
    Public Boolean HasPrevious{ get{ return standardSetCon.getHasPrevious();}set;}
    Public Void First() { standardSetCon.First(); }
    Public Void Last(){ standardSetCon.Last(); }
    Public Void Previous(){ standardSetCon.Previous(); }
    Public Void Next(){
        standardSetCon.Next(); }

}

 
This was selected as the best answer
VSK98VSK98
Hi Suresh,

Suppose if i use custom controller ..........
suresh sanneboina 4suresh sanneboina 4
I used the custom controllet