13

I am showing object fields by using <table>,<tr> and <td> tags in page to show the details in some format. I am using following condition to show data on the page, if field is not blank

<tr>
<td><apex:outputLabel rendered="if field is not blank"><td> 
</tr>

In this code, if field is blank data is not visible but that row is generated and I am getting blank row between two rows.

How to remove this row dynamically?

1
  • Kindly share your code
    – doga
    May 10, 2013 at 5:58

3 Answers 3

13

I tend to do this directly in HTML with some CSS hackery

<tr style="display: {!IF(ISBLANK(Field__c), 'none', 'table-row')};">
    <td>Content of your cell</td>
</tr>
16

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>

<apex:outputPanel> would probably also work as long as you specify layout="none"

1
  • 1
    Note that apex:variable is actually working better than apex:outputPanel. The outputPanel tag does give problems when conditionally hiding tr tags in PDFs. The table somehow breaks when using outputPanel but does not when using apex:variable. May 9, 2018 at 9:47
0

For group of elements we can use apex:outputPanel

<apex:outputPanel layout="none" rendered="{!NOT(ISBLANK(TheField__c))}">
  <tr>
    <td><apex:outputLabel rendered="if field is not blank"><td> 
  </tr>
  .
  .
  .
  .
  <tr>
    <td><apex:outputLabel rendered="if field is not blank"><td> 
  </tr>

</apex:outputPanel>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .