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
DivyaReddyDivyaReddy 

Dispalying more than 1000 records in to pdf.

hi

 

i am one requirement , i have to display all values in accounts. I am posting my controller & visualforce page.

 

public class Raja_Test{
 public Raja_Test(ApexPages.StandardController controller)
    {  }
  public String[] states {get;set;}
  public Account[] ac {get;set;}

 public Raja_Test()
{
ac = [Select id,name,Bill_To__c,Bill_To__r.Name from account where Bill_To__c != NULL ];

Set<String> stateSet = new Set<String>();

    for(Account a : ac)
      
    stateSet.add(a.Bill_To__r.Name);
    states = new String[stateSet.size()];
    Integer i = 0;
    for (String state : stateSet) { 
    states[i] = state;
    i++;
      
   }
states.sort();
}
}

 

 

Visulforce Page :

 

<apex:page Controller="Raja_Test">
<table border = '1'>
  <apex:repeat value="{!states}" var="a">
 <tr>
 <td>{!a}</td>
<tr>
 <td>
 <apex:repeat value="{!ac}" var="a1">
 
<apex:outputPanel rendered="{!IF((a1.Bill_To__r.Name = a) ,true,false)}" >
<td>{!a1.name}</td> 
</apex:outputPanel>

  </apex:repeat>
  </td></tr>
  </tr>
   </apex:repeat>
  </table>
</apex:page>

Can any one help on this 

TheSwamiTheSwami

What is the error message you are getting?

DivyaReddyDivyaReddy

Collection size 1,024 exceeds maximum size of 1,000.

sfdcfoxsfdcfox

You can only have 1,000 items in a list. Instead, use a nested list, which gives you a collective 1,000,000 items that you can store. You'll meet your heap/query limits before this limit, so it happens to be a lot better. The page looks like this:

 

<apex:page controller="test2">
    <apex:repeat value="{!accountlists}" var="index">
        <apex:repeat value="{!accountlists[index]}" var="record">
            {!record.Name}
        </apex:repeat>
    </apex:repeat>
</apex:page>
public class test2 {

    public Map<Integer,List<Account>> getaccountlists() {
        Map<Integer,List<Account>> accounts = new Map<Integer,List<Account>>();
        Integer ctr = 0;
        accounts.put(0,new List<Account>());
        for(Account[] a:[select id,name from account]) {
            if(accounts.get(ctr).size()+a.size()>1000) {
                ctr++;
                accounts.put(ctr,new List<Account>());
            }
            accounts.get(ctr).addAll(a);
        }
        return accounts;
    }

}

 

kiranmutturukiranmutturu

try this as this is a new release you can have this from 23.0 only

 

readOnly attribute on apex:page component  using this you can render 10k records

 

like this

<apex:page controller="MerchandiseController" readOnly="true">

<p>Here is all the merchandise we have:</p>

<apex:dataTable value="{!AllMerchandise}" var="product">

<apex:column>

<apex:facet name="header">Product</apex:facet>

<apex:outputText value="{!product.Name}" />

</apex:column>

</apex:dataTable>

</apex:page>

 

controler:

public class MerchandiseController {

public List<Merchandise__c> getAllMerchandise() {

List<Merchandise__c> theMerchandise =[SELECT Name, Price__c FROM Merchandise__c LIMIT 10000];return(theMerchandise);}

}



DivyaReddyDivyaReddy

it is hitting error as :


Error: Unsupported attribute readonly in <apex:page> in Merchandise at line 1 column 63



kiranmutturukiranmutturu

thats y i told you it is supported in api version 23.0 .. just check with your sandbox is updated to 23.0 r not