On my Visualforce page I've to display more than 5000 records with checkboxes like the following :enter image description here

Here I'm getting 6781 records, but on my vf page it was displaying 100 records only. If I use PAGINATION then I've to select the records which is belongs to that page only. As per my requirement user can select any of the 6781 accounts at a time. Is there any possible way to display all the records in same vf page with side bar.

  • 4
    The page will show what your iteration returns so if it is only showing 100 then you will need to check your query/records. As for displaying thousands of records on a page, I would advise against it as no user can manage parsing through thousands of records. not to mention view state. Suggest you look at implementations like datatables.net and server side data or javascript remoting etc based on your requirements
    – Eric
    Commented Mar 16, 2017 at 17:57
  • 3
    You should really strongly reconsider any requirement that asks you to display more than 1000 records in one place.
    – Adrian Larson
    Commented Mar 16, 2017 at 18:10

2 Answers 2


You can see a deeper discussion here: Maximum number of collection items that can be iterated in an iteration component limit in salesforce

The basic idea is that a Map allows you to iterate basically as many components as you want. View state is still an issue, and I think the requirement to view so many records is completely ridiculous. But it is technically feasible.

In your controller, us a Map<Id, SObject>, or Map<Id, SomeWrapper>, as you like:

public Map<Id, Wrapper> wrappers { get; private set; }

Then on your page you should be able to loop over all of the records:

<apex:pageBlockTable value="{!wrappers}" var="wrapper">
        <apex:inputCheckbox value="{!wrapper.isSelected}" />
    <apex:column value="{!wrapper.record.SomeField__c}" />

You'll lose the ability to control order if you take this approach.


I had a requirement once to load and display thousands of rows to the user without pagination in a Visualforce Page. I also had to have a checkbox for each row and the "select all" functionality, exactly like you. It was a crazy requirement, but I managed to give them what they wanted in the end.

The way I resolved this was by incorporating AngularJS into the VF page and utilizing a directive called infinite-scroll that you can find here.

I would load all row data into JavaScript variable so that I could bind the Angular controller to it. The page would initially render only 200 rows, I believe, and then, whenever the user would scroll down the page the infinite-scroll directive would load another 20 rows, so the user wouldn't even notice that not all rows were loaded at once.

Of course, the page contained a filter functionality at the top (also using Angular), so users were able to filter out the rows, and not scroll down into the abyss to find the desired row.

Also, the select all checkbox was bound to a function that would iterate through all the rows in the model and change the isSelect field to true or false.

That's the way I solved this, I hope this will give you some ideas.

  • Can you share me thae code which you implented for you requirement for my reference.
    – Lokesh
    Commented Mar 17, 2017 at 4:39
  • I don't have the code with me atm, but it shouldn't be too hard for you to implement this if you try. Just start by adding AngularJS to your page and first try to just render out some rows with it using ng-repeat directive. There are lots of Angular tutorials out there. When you get that going, it will be easy to add infinite-scroll directive to it.
    – smukov
    Commented Mar 17, 2017 at 6:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .