Monday, June 24, 2019

Tips and Tricks : Make apex:column value display conditionally

When try to make apex:column display conditionally there high possibility we try to code like below which will prompt Syntax error. Missing ')' .Unfortunately this is documented in any where so far.



<apex:column headerValue="Actual Approver" value="{!IF(item.objectType=='Qualification',item.bid.Actual_Final_Approver__c,item.quote.Actual_Final_Approver__c)}"></apex:column>

apex:column cannot being rendered directly in value tag but we can render it different way like below
    <apex:column headerValue="Actual Approver">
                    <apex:outputField rendered="{!item.objectType=='Qualification'}"
                                      value="{!item.bid.Actual_Final_Approver__c}"/>
                    <apex:outputField rendered="{!item.objectType=='Quote'}"
                                      value="{!item.quote.Actual_Final_Approver__c}"/>
                </apex:column>
The render is done not in value tag in column but use render tag in component like outputText, outputField inside apex:column. Note that using outputField for lookup field will generate standard mini page layout when we mouse over on the link.

Reference : apex:column

No comments:

Post a Comment