Activity Forums Salesforce® Discussions How can we change the colour of Visualforce table dynamically? Reply To: How can we change the colour of Visualforce table dynamically?

  • Tanu

    Member
    August 30, 2016 at 3:03 pm

    Hello Mohit,

    You can assign CSS classes dynamically based on the picklist value using styleClass attrubute:

    Try below code

    <style>
    .errorClass {
    background-color: red;
    }
    .normalClass {
    background-color: green;
    }
    </style>

    <apex:pageBlock>
    <apex:pageBlockTable value="{!testObjectList}" var="item">
    <apex:column value="{!item.name}"
    styleClass="{!IF(item.status__c == 'Critical','errorClass','normalClass')}"/>
    <apex:column value="{!item.status__c}"
    styleClass="{!IF(item.status__c == 'Critical','errorClass','normalClass')}"/>
    </apex:pageBlockTable>
    </apex:pageBlock>