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
Rohit SharmaGRohit SharmaG 

Display more than 10k records in VF page

Hello All,

I would like to display 30k records in the VF page. But as per the Governer limit we can not display 10k with pageblock and repeat.

My list having near 40k records.

please assist on this.

Thanks,
Rohit Sharma
Vikash TiwaryVikash Tiwary
Hi Rohit,

You can use pagination where you load the data in chunks say 10,000 if the page is readonly. Also you can use remote methods to get the recored and fill it in table using javascript. Data returned via remote methods do not contribute to governor limit.

Hope this helps!

Thanks
James LoghryJames Loghry
The iterator in Visualforce can only handle <= 10,000 records.  However, apex can handle more than this.  One trick you can use is to create a "List of Lists", and then nest your apex:repeat elements to iterate over them in Visualforce.  In apex, your code may look like the following:

List<List<String>> myNestedStringList = new List<List<String>>();
Integer i=0;
List<String> currentList = null;
for(sObject sobj : sobjectList){
    if(Math.mod(i,10000)==0){
        currentList = new List<String>();
        myNestedStringList.add(currentList):
    }    
    //Add string to inner array
    currentList.add(sobj.Name);
    i++;
}

Your visualforce would look something like:

<apex:repeat var="outerList" value="{!myNestedStringList}">
    <apex:repeat var="myStr" value="{!outerList}">
        <apex:outputText value="{!myStr}" />
    </apex:repeat>
</apex:repeat>

Please note that storing several records in your Visualforce page / Controller may blow your View State size out of the water, however, so you should be careful with this approach.