2

I am trying to use highlighted columns in a pageBlockTable according to a specific value.

In this code I am trying to give this column a red background, but I keep getting syntax error

Here is my code:

<apex:pageBlockTable value="{!list}" var="d">
  <apex:column style="{!IF({!d.manager== 'user1'},'background:rgb(243, 171, 171);', '')}" >
    <apex:facet name="header">
      <apex:commandLink value="Name"/>
    </apex:facet>
    <apex:outputText value="{!d.Name__c}"></apex:outputText>
  </apex:column>
.
.
.
</apex:pageBlockTable>

1 Answer 1

4

You have {...} rather than (...) surrounding your IF condition, switch those and it should (hopefully) work.

<apex:pageBlockTable value="{!list}" var="d">
    <apex:column style="{!IF(!(d.manager == 'user1)','background:rgb(243, 171, 171);', '')}" >
        <apex:facet name="header">
            <apex:commandLink value="Name"/>
        </apex:facet>
        <apex:outputText value="{!d.Name__c}"></apex:outputText>
    </apex:column>
.
.
.
</apex:pageBlockTable>
5
  • it looks like you still have two opening {'s in there. Theres another before !d
    – Phil B
    Apr 7, 2014 at 14:01
  • @PhilB Good spot, fixed my answer. Apr 7, 2014 at 14:03
  • Yes it was about brackets, thanks guys @alex-tennant and PhilB. Apr 7, 2014 at 14:07
  • @HasanKhatib Don't forget to accept my answer if it's resolved your query to help out future users of the StackExchange. Apr 7, 2014 at 14:21
  • 1
    The negation operator is buggy in certain circumstances of rendering / IF functions within visualforce. Instead of using !, you can simply swap the true / false conditions. e.g. style="{!IF(d.manager == 'user1','','background:rgb(243, 171, 171);')} Apr 7, 2014 at 21:54

You must log in to answer this question.

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