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
N Hemanth kumarN Hemanth kumar 

if you want to display more than 1000 records using pageblocktable.How to acheive?

Best Answer chosen by N Hemanth kumar
Ajay K DubediAjay K Dubedi
Hi Hemanth,

Please go through with the below example. Hope this helps you write your code.

Visualforce page:

<apex:page controller="thousandLimit">    
   <apex:pageBlock >
      <apex:repeat value="{!thousandBlocks}" var="block">
            <apex:pageBlockTable value="{!block.cases}" var="c">
            <apex:column value="{!c.CaseNumber}"/>
            <apex:column value="{!c.owner.name}"/>
            <apex:column value="{!c.App_Process__c}"/>
            <apex:column value="{!c.Load__c}"/>
            <apex:column value="{!c.subject}"/>
            <apex:column value="{!c.Estimated_Completion_Date__c}"/>   
            <apex:column value="{!c.Complete__c}"/>
            <apex:column value="{!c.Priority}"/>
            <apex:column value="{!c.Case_Age_Days__c}"/>                    
            </apex:pageBlockTable>
        </apex:repeat>
     </apex:pageBlock>  
</apex:page>

Apex Controller:

public class thousandLimit
{
    private limitWrapper[] thousandBlocks = new limitWrapper[]{};
    
    private final integer listLimit;
    
    public thousandLimit()
    {
        listLimit = 1000;
    }
    
    public limitWrapper[] getthousandBlocks()
    {
        thousandBlocks = new limitWrapper[]{};
        
        integer counter = 0;
        integer loopCount = 0;
        case[] tmpcase = new case[]{};
        
        for(case c:[select CaseNumber,owner.name,App_Process__c,Load__c,subject,Estimated_Completion_Date__c,Complete__c,Priority,Case_Age_Days__c from Case
                where (Status != 'Closed' or Status != 'Declined') and Estimated_Completion_Date__c = null and owner.Alias like 'EA%' order by owner.name])
        {
            if(counter < listLimit)
            {
                tmpcase.add(c);
                counter++;
            }
            else
            {
                loopCount++;
                thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
                tmpcase = new case[]{};
                tmpcase.add(c);
                counter = 0;
            }            
        }
        
        if(thousandBlocks.size() == 0)
        {
            loopCount++;
            thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
        }
        
        return thousandBlocks;
    }
    
    public class limitWrapper
    {
        public case [] cases {get;set;}
        public integer blockNumber {get;set;}
        public limitWrapper(case[] accs, integer i)
        {
            cases = accs;
            blockNumber = i;
        }
        
    }
}

For more info go through the below links.
http://www.sfdcstuff.com/2017/01/ways-to-resolve-collection-size-xxxx.html
http://blogforce9.blogspot.com/2014/10/showing-more-than-1k-records-using-pbe.html

Please mark as best answer if it helps you.

Thank You,
Ajay Dubedi

All Answers

Niraj Kr SinghNiraj Kr Singh
Hi Hemanth,

You can try this blog to achive this by do some changes like use Transient varibale for list displaying ur records.
https://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/

Let me know if it works for you

Thanks
Niraj
Ajay K DubediAjay K Dubedi
Hi Hemanth,

Please go through with the below example. Hope this helps you write your code.

Visualforce page:

<apex:page controller="thousandLimit">    
   <apex:pageBlock >
      <apex:repeat value="{!thousandBlocks}" var="block">
            <apex:pageBlockTable value="{!block.cases}" var="c">
            <apex:column value="{!c.CaseNumber}"/>
            <apex:column value="{!c.owner.name}"/>
            <apex:column value="{!c.App_Process__c}"/>
            <apex:column value="{!c.Load__c}"/>
            <apex:column value="{!c.subject}"/>
            <apex:column value="{!c.Estimated_Completion_Date__c}"/>   
            <apex:column value="{!c.Complete__c}"/>
            <apex:column value="{!c.Priority}"/>
            <apex:column value="{!c.Case_Age_Days__c}"/>                    
            </apex:pageBlockTable>
        </apex:repeat>
     </apex:pageBlock>  
</apex:page>

Apex Controller:

public class thousandLimit
{
    private limitWrapper[] thousandBlocks = new limitWrapper[]{};
    
    private final integer listLimit;
    
    public thousandLimit()
    {
        listLimit = 1000;
    }
    
    public limitWrapper[] getthousandBlocks()
    {
        thousandBlocks = new limitWrapper[]{};
        
        integer counter = 0;
        integer loopCount = 0;
        case[] tmpcase = new case[]{};
        
        for(case c:[select CaseNumber,owner.name,App_Process__c,Load__c,subject,Estimated_Completion_Date__c,Complete__c,Priority,Case_Age_Days__c from Case
                where (Status != 'Closed' or Status != 'Declined') and Estimated_Completion_Date__c = null and owner.Alias like 'EA%' order by owner.name])
        {
            if(counter < listLimit)
            {
                tmpcase.add(c);
                counter++;
            }
            else
            {
                loopCount++;
                thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
                tmpcase = new case[]{};
                tmpcase.add(c);
                counter = 0;
            }            
        }
        
        if(thousandBlocks.size() == 0)
        {
            loopCount++;
            thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
        }
        
        return thousandBlocks;
    }
    
    public class limitWrapper
    {
        public case [] cases {get;set;}
        public integer blockNumber {get;set;}
        public limitWrapper(case[] accs, integer i)
        {
            cases = accs;
            blockNumber = i;
        }
        
    }
}

For more info go through the below links.
http://www.sfdcstuff.com/2017/01/ways-to-resolve-collection-size-xxxx.html
http://blogforce9.blogspot.com/2014/10/showing-more-than-1k-records-using-pbe.html

Please mark as best answer if it helps you.

Thank You,
Ajay Dubedi
This was selected as the best answer