0

I have a scenario to change color of text to red when a checkbox is true.

There are 3 columns in pageblock table(output field's).

The third coloumn is of type lookup and has a hyperlink to it, redirecting to that record.

Now the issue is color is changing fine for first two coluns but not for 3'rd column.

vf page:

<apex:pageBlockTable value="{!thevalue}" var="i">
                    <apex:column headerValue="Name">
                    <font color="{!if(i.checkbox,'#ff0000','#000000')}">
                    <apex:outputText value="{!i.name}"></apex:outputText>
                    </font>
                    </apex:column>
                    <apex:column headerValue="Date">
                    <font color="{!if(i.checkbox,'#ff0000','#000000')}">
                    <apex:outputField value="{!i.Date__c}"/>
                    </font>
                     </apex:column>
                    <apex:column headerValue="Location">
                    <font color="{!if(i.checkbox,'#ff0000','#000000')}">
                     <apex:outputfield value="{!i.Location__c}"/>
                     </font>
                    </apex:column>


                 </apex:pageblocktable>

enter image description here

1 Answer 1

1

The out-of-the-box style sheet for links is interfering with with the font's color attribute. Furthermore, apex:outputField doesn't seem to support style or styleClass correctly, despite being in the documentation. I could only get this working by actually creating the link directly:

<apex:outputLink value="{!URLFOR($Action.Location__c.View, i.Location__c, [id=i.Location__c])}"
                 style="color: {!if(i.checkbox,'#f00','#000')}">             
    {!i.Location__r.Name}
</outputLink>

Your mileage may vary.

3
  • It says Invalid parameter for function URLFOR Error is in expression '{!URLFOR($Action.Location__c.View, i.Location__c, [id=i.Location__c])}' in component <apex:outputLink>
    – Anurag
    Commented Aug 26, 2016 at 20:01
  • @AnuragA Replace $Action.Location__c.View with the name of your object (I just guessed, because I don't know what it is).
    – sfdcfox
    Commented Aug 26, 2016 at 20:03
  • Thats the correct object name
    – Anurag
    Commented Aug 26, 2016 at 20:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .