Making the color for each cell in a pageblocktable based on condition
Hi,
I am trying to show you how to change the colors of cells of pageBlockTable in visualforce based on condition
and also show you how to place the string literal in the cells based condition.
Here I have created an object with the name called Employeetest__c and having three fields are
Name(text),Status__c(checkbox),Salary__c(number).
Requirement:
When the salary>=XXX and salary<XXX then make the color for that cell under the Salary column.
Like that for different conditions we need to set different colors for each cell based on condition.
and When status checkbox is checked then then place the "Active" in the cell under the Status column otherwise
place the "InActive" as string literals.
controller:
=======
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;
}
}
page:
======
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;
}
}
Output:
======
![]() |
VFpage with colors and string literals based oncondition |
Try this all the best
where is the code for the color
ReplyDelete