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

  • How can we change the colour of Visualforce table dynamically?

    Posted by Mohit on August 30, 2016 at 2:05 pm

    Hi All,

    How can we change the colour of Visualforce table dynamically?

    I am in scenario in which I want to set the colour of table set such that the is user chose something from the picklist then that particular colour type of row is shown

    Eg: In case if he choose the stage Closed, Open, Critical then that particular row must be fill with  these colour red,green,blue respectively.

    Please give suggestion

     

    Tanu replied 7 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • 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>

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos