0

I would like to conditionally render a column on my VF Page however does not appear to play nicely/support "rendered" logic. Any Help is appreciated!

<apex:column>     
    <apex:outputText value="{!a.Condition.ImpsHostedfromOutsideSource__c}" 
       rendered="{IF(!a.Condition.MRMFee__c == 'Visitor Data Hosting 
       Fees',true,false)}"></apex:outputText>
    <apex:inputField value="{!a.Condition.ImpsHostedfromOutsideSource__c}" 
       rendered="{!a.Condition.MRMFee__c == 'Visitor Data Hosting Fees'}">
    </apex:inputField>
</apex:column>

enter image description here

0

You can use the headerValue attribute of <apex:column> to display the column header.

Excerpt from the above mentioned documentation

headerValue

The text that should be displayed in the column header. If you specify a value for this attribute, you cannot use the column's header facet. Note also that specifying a value for this attribute overrides the default header label that appears if you use an inputField or outputField in the column body.

So your code would be

<apex:column headerValue="yourColumnName"> 
    <apex:outputText value="{!a.Condition.ImpsHostedfromOutsideSource__c}" rendered="{IF(!a.Condition.MRMFee__c == 'Visitor Data Hosting Fees',true,false)}"></apex:outputText> 
    <apex:inputField value="{!a.Condition.ImpsHostedfromOutsideSource__c}" rendered="{!a.Condition.MRMFee__c == 'Visitor Data Hosting Fees'}"> </apex:inputField> 
</apex:column>

And if you want the entire column to be rendered based on a condition then you can use the rendered attribute of <apex:column>

rendered

A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true.

<apex:column headerValue="yourColumnName" rendered="false"> 
    <apex:outputText value="{!a.Condition.ImpsHostedfromOutsideSource__c}" rendered="{IF(!a.Condition.MRMFee__c == 'Visitor Data Hosting Fees',true,false)}"></apex:outputText> 
    <apex:inputField value="{!a.Condition.ImpsHostedfromOutsideSource__c}" rendered="{!a.Condition.MRMFee__c == 'Visitor Data Hosting Fees'}"> </apex:inputField> 
</apex:column>

I have added rendered="false" in the above mentioned code, you will have to replace it with your condition.

| improve this answer | |
  • Okay thanks Vijay, however, I would like to only conditionally render the column name when these conditions are met. Is this possible? The dynamic render logic seems to work properly for the inputfield. Using your solution, the column name would be always present on the page. – FWSFDC Sep 11 '19 at 18:51
  • Yes you can, column also has rendered attribute which can be used. Updated the answer. – Vijay Ganji Sep 11 '19 at 18:55
  • Vijay - I updated the code, however, now the column nor the inputfield is no longer displaying entirely. I think the rendered ="false" may have something to do with it. Appreciate your help. – FWSFDC Sep 11 '19 at 19:02
  • Yes rendered is used for that very reason, you will have to replace false with your condition. – Vijay Ganji Sep 11 '19 at 19:11
  • No dice. I'm guessing there is some limitation in Salesforce that is preventing this. – FWSFDC Sep 11 '19 at 19:14

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.