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
Tony Mann 9Tony Mann 9 

Have Table only Render in VF Template when Object is Populated

Hello,

I have code that populates a table from a custom object in my VF email template. I want to have it so the table only shows when their is data in the custom object. Including the header. Code below. 

Is it possible? 

Thanks!

<br><b>Related Family</b></br>   
<br></br>
          <table border="0" >
            <tr >
               <th>Name</th>
               <th>Relationship</th>
               <th>Date of Birth</th>
               <th>Notes</th>
            </tr>
            <apex:repeat var="cx" value="{!relatedTo.Related_Guests__r}">
              <tr>
                <td>{!cx.Name}</td>
                <td>{!cx.Type__c}</td>
                <td>{!cx.Date_of_Birth__c}</td>
                <td>{!cx.Notes__c}</td>
              </tr>
            </apex:repeat>                
          </table>
Ayush TripathiAyush Tripathi
Hi Tony
Use  <apex:outputPanel  rendered="{!dataList}"/>
Inside this write your table
<apex:outputPanel>

dataList will be the list of the records that you will be returning from the controller. So if the list will be empty then the table will not be rendered.