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
HarryHHHarryHH 

PDF Pagination and List of Lists

Hello,

 

I have the need to generate very big invoices with many positions that don't fit on one page. At a code view session at the dreamforce a salesforce developer told me to create a list of lists with the invoicepositions. Each List of the inner Lists contains the invoicepositions for one page. If I do so I have the problem to get only one list of the lists. I don't know how to do that with the apex:datatable tag. Here is my getter method:

 

    public List<List<Tourzusammenfassung__c>> getTourzusammenfassung()
    {
        List<List<Tourzusammenfassung__c>> TZ;
        return TZ;
    }

 

And here my page:

 

        <apex:dataTable value="{!Tourzusammenfassung[0]}" var="TZ" id="theList" styleClass="my_table">
            <apex:facet name="header"></apex:facet>
            <apex:column >
                <apex:facet name="header">TourNr.</apex:facet>
                <apex:Outputtext value="{!TZ.Tourmodell__r.name}"/>
            </apex:column>
      </apex:datatable>

 

But this does not work. Can anyone help me on this. If there are any other soltions for paginated PDF's let me know please!

 

Thanks

Harry.

Jim BoudreauxJim Boudreaux

I am assuming your apex code is truncated, or are you really trying to return an uninstantiated List of Lists? Without giving your problem too much thought, it occurs to me that you should instantiate your list of lists with a constructor, and then fill it with the results of a soql query and subquery.

Something like this:

 

public List<List<Tourzumthingorother__c>> getTourzumthingorother(){
   List<List<Tourzumthingorother__c>> TZ = new List<List<Tourzumthingorother__c>>();
   for(Tourzumthingorother__c tz : [select id, name, cf__c, (select id, name, cf__c from Tourzumthingorothers__r) from Tourzumthingorother__c]){
      List<Tourzumthingorother__c> innerlist = new List<Tourzumthingorother__c>();
      for(Tourzumthingorother__c innertz : tz.Tourzumthingorothers__r){
         innerlist.add(innertz);
      }
      TZ.add(innerlist);
   }
   return TZ;
}

 

I haven't checked the above code and it is only being provided as an example of how you need to construct and fill a List of Lists (an Inception List if you will). This may or may not be your problem, take it or leave it.

 

HarryHHHarryHH

Hello Jim,

 

thanks for your reply. You are right and I should have written, that the controller code is truncated. I only wanted o show that I pass a List of Lists to the page. In the system-debug I've seen that this list is correct. I have the problem not knowing how to access one of these lists in an apex:datatble. The statement

 

<apex:dataTable value="{!Tourzusammenfassung[0]}" var="TZ" id="theList" styleClass="my_table">

 

does not work. If anyone can answer me that question, he or she will probably be able to also answer my next question: I shurely don't want to only access the first list, but I do want to access all these lists. Therefore I need a varaible lets say "index" in the page that runs thrugh all these lists like this:

 

<apex:dataTable value="{!Tourzusammenfassung[index]}" var="TZ" id="theList" styleClass="my_table">

 

Can you help? Thanks very much!

 

Harry