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
Lukas R.Lukas R. 

Generate fixed grid 3 x 8 from campaign members

Hi,
I need to be able to send hard copy invitation for campaign members and I need to generate list of labels with names/addresses of contacts and these labels would be later used for envelopes with the invitation. This list of labels needs to be 3 columns x 8 rows. We have proffesional edition so I cannot use apex, only visualforce. Im trying my luck with the code below, but Im not good at that. Columns are responsive so they change the width according to cell content and still dont know how to specify fixed number of rows per page. Many thanks for help
<apex:page standardController="Campaign" showHeader="false" applyBodyTag="false" >

      <apex:pageBlock >
          <apex:pageBlockSection columns="3" showHeader="false">
                <apex:repeat value="{!Campaign.CampaignMembers}" var="line" >   
                    <apex:pageBlockSectionItem rendered="{!line.Status='Sent'}" dataStyle="width:33%" labelStyle="width:33%" >
    
                    {!line.Contact.Name}<BR/>
                    {!line.Contact.MailingStreet}<BR/>
                    {!line.Contact.MailingPostalCode} {!line.Contact.MailingCity}<BR/>
                    {!line.Contact.MailingCountry}<BR/>  
                    
                    </apex:pageBlockSectionItem>
                </apex:repeat>
          </apex:pageBlockSection>
      </apex:pageBlock> 
      
    
</apex:page>
sslodhi87sslodhi87
Hi Lukas,

You can fixed the rows by using apex attributes first="0" rows="8"
<apex:page standardController="Campaign" showHeader="false" applyBodyTag="false" >\
      <apex:pageBlock >
          <apex:pageBlockSection columns="3" showHeader="false">
                <apex:repeat value="{!Campaign.CampaignMembers}" var="line" first="0" rows="8">   
                    <apex:pageBlockSectionItem rendered="{!line.Status='Sent'}" dataStyle="width:33%" labelStyle="width:33%" >
    
                    {!line.Contact.Name}<BR/>
                    {!line.Contact.MailingStreet}<BR/>
                    {!line.Contact.MailingPostalCode} {!line.Contact.MailingCity}<BR/>
                    {!line.Contact.MailingCountry}<BR/>  
                    </apex:pageBlockSectionItem>
                </apex:repeat>
          </apex:pageBlockSection>
      </apex:pageBlock> 
</apex:page>

Please let me know if this helps you.

Thanks
 
sslodhi87sslodhi87
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_repeat.htm
Lukas R.Lukas R.
Hi sslodhi87,
Im afraid that is not what I wanted, the 'rows' attribute returns me the maximum number of items in the collection that is rendered. But the idea is not to render only one page with contacts. For example in case I had 100 campaign members for the campaign I would need several pages to be generated, because I would need 24 items per page fixed (3 columns x 8 rows) to be generated on the page, so specifically in this case it would be 5 pages in total and there would be only 4 contacts on the last page. Does it make sense? Thank you
Laxman1975Laxman1975
You can do this by one trick -

Have <apex:var> which will work like a counter.

Have html code like this

<table>

<apex:repeat>
<!--This will be conditional TR when counter reach 3 -->
<tr>
<td>Add data column data here</td>
<!--increment counter by 1//-->
<!--This will be conditional TR when counter reach 3 -->
</tr>
</apex:repeat>
</table>

So it will have 3 Column and number rows as per available records.