Print this page

How to change font color in a VisualForce table conditionally?

Knowledge Article Number 000193671
Description Issue -
Developer needs to change the font color in a table conditionally in a VisualForce page
Resolution
Here's a small piece of sample code to change font color conditionally in a VF table. 
Following is a VF Page that display Accounts in red if the account name is Burberry
///////////////////////////////////////////////////////////////////////// 
<apex:page standardcontroller="Account"> 
<apex:pageBlock> 
<apex:pageBlockTable value="{!account}" var="item"> 
<apex:column> 
<font color="{!if(item.name='Burberry','#ff0000','#00ff00')}"> 
<apex:outputtext value="{!item.name}" /> 
</font> 
</apex:column> 
</apex:pageBlockTable> 
</apex:pageBlock> 
</apex:page> 
 




promote demote