Thursday, 19 December 2013

Changing the colors for each cell in the pageblocktable


I have an object Employeetest__c with fields Name(Text),Status__c(check box) and Salary__c(Number)

Now  i want to change the color of each cell under the Salary column based on condition(for eg:if "salary<5000 then red color otherwise blue etc..) and placing the String literal for each cell under the Status column. (when checkbox is  checked it should be "Active" otherwise "InActive").

For i am writing a controller below:

public class employeetestController{

    public List<Employeetest__c> lstemp=new List<Employeetest__c>();
    public List<Employeetest__c> getrecs(){
        lstemp=[select name,salary__c,status__c from Employeetest__c];
        return lstemp;

I am writing visualforce page using the above controller as shown below:

<apex:page controller="employeetestController"  sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageblocktable value="{!recs}" var="e">
<apex:column value="{!}"/>

<apex:column >
<apex:facet name="header">Salary</apex:facet>
<div style="background-color:{!If(e.Salary__c>=7000 &&    e.Salary__c<10000,'#7CFC00',If(e.Salary__c>=10000 && e.Salary__c<100000,'#DEB887','#DC143C'))}">
<apex:column >
<apex:facet name="header">Status</apex:facet>

No comments:

Post a Comment

Create Dynamic Picklists for Your Custom Components (design:component)

Hi, We can expose a component property as a picklist when the component is configured in the Lightning App Builder. The picklist’s value...