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
streetstreet 

Retrieve all the records from custom object

I have a requirement to retrieve all the records from "Customer" object and to display them on Visualforce page.

 

Where "Customer" contains aroung 4000 to 5000 records.

 

 

 

 

 

 

srikeerthisrikeerthi

Hi

 

You can use Standardsetcontroller to display 2000 records per page and then you have

to go for pagination for the rest of records,Please refer the following link for standardsetcontroller

http://www.salesforce.com/us/developer/docs/pages/Content/apex_pages_standardsetcontroller.htm.

 

 

 Thanks

streetstreet

Can you help me out with a sample code... how actually its works.

srikeerthisrikeerthi



Hi

 

You can implement the Standardsetcontroller in this way

 

page

<apex:page controller="opportunityList2Con">   

<apex:pageBlock >

        <apex:pageBlockTable value="{!opportunities}" var="o">     

      <apex:column value="{!o.name}"/>   

        <apex:column value="{!o.closedate}"/> 

      </apex:pageBlockTable>   

</apex:pageBlock>

</apex:page>

 

Class :

 

public class opportunityList2Con {

 // ApexPages.StandardSetController must be instantiated

       // for standard list controllers

         public ApexPages.StandardSetController setCon { 

      get { 

          if(setCon == null) {

                setCon = new ApexPages.StandardSetController(Database.getQueryLocator( [select name,closedate from Opportunity]));       

    }

            return setCon;   

    } 

      set;

    }

    // Initialize setCon and return a list of records      

    public List<Opportunity> getOpportunities() { 

       return (List<Opportunity>) setCon.getRecords();    }}

 

Thanks

 

streetstreet

Its not helping me out....just it retrieving 19 records...

 



 

public class opportunityList2Con {
  // ApexPages.StandardSetController must be instantiated  
    
  // for standard list controllers  
    
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select name,Verification_Date__c,Bank__c from account]));
            }
            return setCon;
        }
        set;
    }

    // Initialize setCon and return a list of records  
    
    public List<account> getOpportunities() {
         return (List<account>) setCon.getRecords();
    }
}
 

 

<apex:page controller="opportunityList2Con" contenttype="application/vnd.ms-excel">
<apex:repeat value="{!opportunities}" var="o">
{!o.name}
{!o.Verification_Date__c}

</apex:repeat>



  
</apex:page>