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
Zane Prater 15Zane Prater 15 

How to Show/hide an html table in visualforce template

I have a template that pulls in related records from a vf component and want to hide when there are no records rather than showing an empty table.  
 
<!---adding table------->
     <table STYLE="{!IF(relatedto.Number_of_Lines__c == 0, 'display:none;','')}" type="text/css">
        table {
            
            border-width: 0px;
            border-spacing: 5px;
            <!--border-style: solid;
            border-color: #FF0000;-->
            background-color: #b0b7bc;
        }
 
        td {
            text-align: center;
            color: #FFFFFF;
            border-width: 0px;
            padding: 0px;
            <!--border-style: solid;
            border-color: #000000;-->
            background-color: #013b59;
        }
 
        th { 
            text-align: center;
            color: #FFFFFF;
            border-width: 0px ;
            padding: 4px ;
            border-style: none ;
            border-color: #000000;
            background-color: #013b59;
        }
        
     </table>
     <font face="arial" size="2">
     
     <table border="50">

    <td><c:ReturnCRItems cse_id="{!relatedTo.id}"></c:ReturnCRItems></td>
    </table></font>

 
Best Answer chosen by Zane Prater 15
PriyaPriya (Salesforce Developers) 
Hi Zane,

You should be able to control the rendering of the row using <apex:variable>:
<apex:variable var="v" value="" rendered="{!NOT(ISBLANK(TheField__c))}">
  <tr>
    <td><apex:outputLabel rendered="if field is not blank"><td> 
  </tr>
</apex:variable>

For more detail refer this :- 

https://salesforce.stackexchange.com/questions/11554/hide-the-whole-empty-row-of-table-in-vf-page-when-rendered-as-pdf

 

Please mark it as best answer if it helps you.

Regards,

Priya Ranjan