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
Michael MMichael M 

rendered not working in table in vf page

Hello, I need to render a row of my table conditionally. However the "rendered" tag is not working. I don't want to use <apex:outputPanel> around the row, because then it breaks up the table and makes extra spacing that doesn't look nice. Is there a way to get this to work in the <tr> tag itself?

 <table >
 <tr rendered="{!IF(spellFromDate2 ='',false,true)}">
             <th>SPELL</th>
            <th>{!spellFromDate2}</th>
          <th>{!spellToDate2 }</th>
         <th>{!spellHospFullDays2 }</th>
         <th>{!spellHospCoinsDays2 }</th>
         <th>{!snfFullDays2 }</th>
            <th>{!snfCoinsDays2 }</th>
          <th style="border-left: 1px solid black;"></th>
         <th></th>
         <th></th>
      </tr> 

  <tr>
             <th>SPELL</th>
            <th>{!spellFromDate3}</th>
          <th>{!spellToDate3 }</th>
         <th>{!spellHospFullDays3 }</th>
         <th>{!spellHospCoinsDays3 }</th>
         <th>{!snfFullDays3 }</th>
            <th>{!snfCoinsDays3 }</th>
          <th style="border-left: 1px solid black;"></th>
         <th></th>
         <th></th>
      </tr> 
</table>
Best Answer chosen by Michael M
ANUTEJANUTEJ (Salesforce Developers) 
Hi Michael,

As mentioned in this link https://salesforce.stackexchange.com/questions/13348/rerender-standard-html-element-from-visualforce-component it would not be possible for Visualforce cannot re-render any element that is not managed by the view state. can you try checking the above link once.

Regards,
Anutej 

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Michael,

As mentioned in this link https://salesforce.stackexchange.com/questions/13348/rerender-standard-html-element-from-visualforce-component it would not be possible for Visualforce cannot re-render any element that is not managed by the view state. can you try checking the above link once.

Regards,
Anutej 
This was selected as the best answer
Michael MMichael M
Hi Anutej,

Ah I see. What would you recommend I do?
Michael MMichael M
Is there a way to surround it with <apex:outputPanel> without it messing up the layout of the table? (It seems to make uneven spacing and messes up the columns when I tried it)
ANUTEJANUTEJ (Salesforce Developers) 
Can you try using tags that are managed as in <apex:pageBlockTable> with <apex:column> with outputpanel as these are the ones supported?

Is there any specific reason for using HTML tags?
Michael MMichael M
I can- I just like how the table looks a little more.. Thank you - i appreciate it.
ANUTEJANUTEJ (Salesforce Developers) 
Ohh, I will try looking at it and In case if I find any information that could help I will update this thread.
Michael MMichael M
i actually noticed now that the table rows sort of render themselves. If there's no data then it doesn't really take up blank space, instead it just doesn't really show that space. And I can render the table within a pageblocksection, and render the entire section which is helpful. Thanks!