12

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?

  • Kindly share your code – doga May 10 '13 at 5:58
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>
| improve this answer | |
15

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"

| improve this answer | |
  • 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. – Willem Mulder May 9 '18 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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.