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
Alex Waddell 18Alex Waddell 18 

Limit apex repeat to 2 per page

Hello,

I am looking for a way to limit the number of tables created by an apex:repeat that appears on any given page.

I would like to limit the number to 2 per page. due to varying data, the tables vary in size. So sometimes the tables get pushed onto the next page causing a very ugly VF page as shown belowUser-added image
<apex:page Controller="ResourceListController" renderAs="PDF" >
    <apex:form >
    <div style="text-align:center">
            <apex:image id="AdobeLogo" value="{!'/servlet/servlet.FileDownload?file= 0151R000004zUAh'}" width="50%" height="90" />
            </div>
        <br></br>
    <br></br>
<br></br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        <br></br>
    <br></br>
<br></br> 
Please contact Adobe Care and Wellness at 4807205699 for any questions regarding your Resource List.
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>
<div style="text-align:center">
            <apex:image id="ArizonaLandScape" value="{!'/servlet/servlet.FileDownload?file= 0151R000005BPCa'}" width="75%" height="75%"/>
           </div>

<div style="page-break-after:always;">
</div>
<br></br>
<br></br>
<br></br>

    <apex:repeat var="RL" value="{!ResourceList}"> 
        <table border="1" style="width:100%" >
            <tr>
            <th >Name</th>
                </tr>
            <tr>
          <td>{!RL.Account__r.Name}</td>
                </tr>
                       <tr>
            <th>Description</th>
                </tr>
            <tr>
          <td>{!RL.Account__r.Description}</td>
                </tr>
           <tr>
            <th>Address</th>
           </tr>
            <tr>
          <td>{!RL.Account__r.BillingStreet}<br></br> 
            {!RL.Account__r.BillingCity}, {!RL.Account__r.BillingState} {!RL.Account__r.BillingPostalCode} </td>
                </tr>

            
        </table>
        <table border="1" style="Width:100%">
         <tr>
            <th>Phone</th><th>Type</th><th>Distance</th>
           </tr>
        
                    <tr>
          <td>{!RL.Account__r.Phone}</td><td>{!RL.Type__c}</td><td>{!RL.Distance__c} miles</td>
                </tr>
            </table>
<br></br>
<br></br>
<br></br>
<br></br>
<br></br>




     </Apex:Repeat>
                 
        </apex:form>
</apex:page>

 
ShirishaShirisha (Salesforce Developers) 
Hi Alex,

Greetings!

I don't think we have any possible way to limit the iteration per page as it depends on the data that you are working on the repeat tag.

Please refer the below documentation for more details on this:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri