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

panelGrid rendered not working as expected

I have an interesting situation which I can't seem to figure out.  I have a page which iterates over a list of Objects.  Each object has some basic data and then a list of fields and values (it is it's own wrapper class).


I render the basic data in a repeat loop, then a nested repeat loops through the fields and values.  When I simply use rendered="true" everything looks fine.  However I would like to display only those values which are NOT labeled 'Not Enabled' and are not null.  For some reason when i changed rendered to rendered="{!AND(f.value!='Not Enabled',f.value!=null)} the values I want are printed but sometimes with huge gaps between the lines, ie:


Field 1:  Value 1

Field 2:  Value 2



Field3:  Value 3

Field4:  Value 4


Here is the VF code


<apex:page controller="printIDscontroller" showHeader="false" sidebar="false" renderas="pdf" title="User IDs"> <apex:panelGrid columns="1" width="100%" > Login IDs for Account:<b>{!accountName}</b> on Order Request <b>{!OrderReqNum}</b><br/><br/> </apex:PanelGrid> <apex:repeat value="{!printIDs}" var="i" id="table"> User ID:<b>{!i.tulid.Name}</b> <apex:panelGrid columns="3" cellspacing="4" width="80%"> <apex:panelGroup > <apex:outputLabel value="Login Location:"/>&nbsp;<apex:outputText value="{!i.tulid.Login_Location__c}" /> </apex:panelGroup> <apex:panelGroup > <apex:outputLabel value="Exchange Type:"/>&nbsp;<apex:outputText value="{!i.tulid.Exchange_Type__c}" /> </apex:panelGroup> </apex:panelGrid> <apex:repeat value="{!i.theList}" var="f" id="fields"> <apex:panelGrid columns="3" width="100%"> <apex:panelGroup rendered="{!AND(f.value!='Not Enabled',f.value!=null)}"> <apex:outputText value="{!f.label}"/><apex:outputText value=": "/><apex:outputText value="{!f.value}"/> </apex:panelGroup> </apex:panelGrid> </apex:repeat> </apex:repeat> </apex:page>


 Any insight would be appreciated.


Best Answer chosen by Admin (Salesforce Developers) 
Note that the panelGrid component that surrounds the conditionally rendered panelGroup is *always* being rendered, even if it's empty.Try moving the rendered property up onto the panelGrid.