+ Start a Discussion
SoundarSoundar 

alternate background color based on date

i want to assign different background color based on date...for example four row having the same date it should be shown the different color.      thanks in advance
SoundarSoundar
i want to assign different background color based on date...for example four row having the same date it should be shown in the  Same color.     ----->thanks in advance <--
kiranmutturukiranmutturu
You can set the column color using Style attribute like below

style="{!IF(object.field != 5,'background-color:green;',background-color:red;')}"
SoundarSoundar
Hi kiran_mutturu, Thanks for reply , 

here i have attached screenshot and coding also .... could you please rectify this .  here i need output as per mentioned above screenshot , i need all the records based on the inspection date (recently created date should be show top of the record EX-  i have three records , 18/04/2016 , 17/04./2016 , 19/04/2016 . here 19/04/2016 wil show top of the page )

@VF Page

<apex:page showHeader="false" tabstyle="Quote__c" extensions="PreviousVisitAllCertificate" standardController="Inspection_Sheet__c">
<!--<style>
tr:nth-child(even) {background: #DBE5F1}
</style>-->
  
  <apex:form >
  
  <apex:pageblock >
  
   <apex:pageblockSection columns="1" >
   <apex:facet name="header">System Types</apex:facet>
   <apex:variable var="i" value="{!0}"/> 
   <apex:repeat value="{!systemType}" var="Systype">
   <apex:outputLabel >{!Systype}</apex:outputLabel>
   <apex:variable var="i" value="{!i+1}"/> 
   <apex:pageBlockTable value="{!systemType[Systype]}" var="Sys" style="background-color:{! IF((mod(i,2)) == 1,'#DBE5F1','#FDE9D9')};">
   <apex:column value="{!Sys.Inspection_Sheet__r.Date__c}" headerClass="headerStyle" headerValue="Inspection Date" />
   <apex:column value="{!Sys.Name}"  headerClass="headerStyle"/>
   <apex:column value="{!Sys.Building__c}" headerClass="headerStyle"/>
   <apex:column value="{!Sys.System_Type__c}" headerClass="headerStyle"/>
   <apex:column value="{!Sys.Type__c }" headerClass="headerStyle"/>
   <apex:column value="{!Sys.System_Location__c}" headerClass="headerStyle"/>
   <apex:column value="{!Sys.Pass__c}" headerClass="headerStyle"/>
   <apex:column value="{!Sys.Fail__c}" headerClass="headerStyle"/>
   </apex:pageBlockTable>
   </apex:repeat>
  <apex:outputLabel >{!systemType}</apex:outputLabel>
   </apex:pageblockSection> 
   </apex:pageblock>
   </apex:form>
  </apex:page>




@Controler

public class PreviousVisitAllCertificate{


private ApexPages.StandardController controller {get; set;}
public Map<id,Inspection_Sheet__c> Inspec;
public Inspection_Sheet__c VisName{get;set;}
public Visit__c VisitId{get;set;}
public Map<id,List<System_Type__c>> systemType {get;set;}
public List<Other_System__c> otherSystem {get;set;}
public id propertyId;
public List<System_Type__c> SortType{get;set;} 
   
    public PreviousVisitAllCertificate(ApexPages.StandardController controller) {
       //Inspec=new Map<Id,Inspection_Sheet__c>();
       SortType=new List<System_Type__c>();
       systemType=new Map<id,List<System_Type__c>>();
        VisName=[select Visit__r.Name,Porperty_Id__c from Inspection_Sheet__c where id=:ApexPages.CurrentPage().getparameters().get('id')];
        if(VisName!=null){
        propertyId=(Id)VisName.Porperty_Id__c;
        VisitId=[select id,Name,Property__c from Visit__c where Property__c=:propertyId AND Name<:VisName.Visit__r.Name order by createddate desc limit 1];
        }
        if(VisitId!=null){
     
        Inspec=new Map<Id,Inspection_Sheet__c>([select id,Name,Date__c from Inspection_Sheet__c where Visit__c in(select id  from Visit__c where id=:VisitId.id) ORDER BY Date__c]);
        
        SortType=[SELECT id,Name,Building__c,System_Location__c,System_Type__c,Type__c,createdDate,Pass__c,Fail__c,Inspection_Sheet__r.Date__c FROM System_Type__c WHERE Inspection_Sheet__c in:(Inspec.keyset()) order by Inspection_Sheet__r.Date__c desc];
        
        system.debug('>>>>>'+SortType);
        
            for(System_Type__c Sys: SortType){
              if(systemType.containskey(Sys.Inspection_Sheet__c)){
              systemType.get(Sys.Inspection_Sheet__c).add(Sys);
              }
              else{
              systemType.put(Sys.Inspection_Sheet__c,new List<System_Type__c>{Sys});
              }
            }
        }
    }

}




 
SoundarSoundar
Hi&nbsp;kiran_mutturu, Thanks for reply ,&nbsp;  here i have attached screenshot and coding also .... could you please rectify this . &nbsp;here i need output as per mentioned above screenshot , i need all the records based on the inspection date (recently created date should be show top of the record EX- &nbsp;i have three records , 18/04/2016 , 17/04./2016 , 19/04/2016 . here 19/04/2016 wil show top of the page )  @VF Page  <apex:page showHeader="false" tabstyle="Quote__c" extensions="PreviousVisitAllCertificate" standardController="Inspection_Sheet__c"> <!--<style> tr:nth-child(even) {background: #DBE5F1} </style>--> &nbsp;&nbsp; &nbsp; <apex:form > &nbsp;&nbsp; &nbsp; <apex:pageblock > &nbsp;&nbsp; &nbsp; &nbsp;<apex:pageblockSection columns="1" > &nbsp; &nbsp;<apex:facet name="header">System Types</apex:facet> &nbsp; &nbsp;<apex:variable var="i" value="{!0}"/>&nbsp; &nbsp; &nbsp;<apex:repeat value="{!systemType}" var="Systype"> &nbsp; &nbsp;<apex:outputLabel >{!Systype}</apex:outputLabel> &nbsp; &nbsp;<apex:variable var="i" value="{!i+1}"/>&nbsp; &nbsp; &nbsp;<apex:pageBlockTable value="{!systemType[Systype]}" var="Sys" style="background-color:{! IF((mod(i,2)) == 1,'#DBE5F1','#FDE9D9')};"> &nbsp; &nbsp;<apex:column value="{!Sys.Inspection_Sheet__r.Date__c}" headerClass="headerStyle" headerValue="Inspection Date" /> &nbsp; &nbsp;<apex:column value="{!Sys.Name}" &nbsp;headerClass="headerStyle"/> &nbsp; &nbsp;<apex:column value="{!Sys.Building__c}" headerClass="headerStyle"/> &nbsp; &nbsp;<apex:column value="{!Sys.System_Type__c}" headerClass="headerStyle"/> &nbsp; &nbsp;<apex:column value="{!Sys.Type__c }" headerClass="headerStyle"/> &nbsp; &nbsp;<apex:column value="{!Sys.System_Location__c}" headerClass="headerStyle"/> &nbsp; &nbsp;<apex:column value="{!Sys.Pass__c}" headerClass="headerStyle"/> &nbsp; &nbsp;<apex:column value="{!Sys.Fail__c}" headerClass="headerStyle"/> &nbsp; &nbsp;</apex:pageBlockTable> &nbsp; &nbsp;</apex:repeat> &nbsp; <apex:outputLabel >{!systemType}</apex:outputLabel> &nbsp; &nbsp;</apex:pageblockSection>&nbsp; &nbsp; &nbsp;</apex:pageblock> &nbsp; &nbsp;</apex:form> &nbsp; </apex:page>     @Controler  public class PreviousVisitAllCertificate{   private ApexPages.StandardController controller {get; set;} public Map<id,Inspection_Sheet__c> Inspec; public Inspection_Sheet__c VisName{get;set;} public Visit__c VisitId{get;set;} public Map<id,List<System_Type__c>> systemType {get;set;} public List<Other_System__c> otherSystem {get;set;} public id propertyId; public List<System_Type__c> SortType{get;set;}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public PreviousVisitAllCertificate(ApexPages.StandardController controller) { &nbsp; &nbsp; &nbsp; &nbsp;//Inspec=new Map<Id,Inspection_Sheet__c>(); &nbsp; &nbsp; &nbsp; &nbsp;SortType=new List<System_Type__c>(); &nbsp; &nbsp; &nbsp; &nbsp;systemType=new Map<id,List<System_Type__c>>(); &nbsp; &nbsp; &nbsp; &nbsp; VisName=[select Visit__r.Name,Porperty_Id__c from Inspection_Sheet__c where id=:ApexPages.CurrentPage().getparameters().get('id')]; &nbsp; &nbsp; &nbsp; &nbsp; if(VisName!=null){ &nbsp; &nbsp; &nbsp; &nbsp; propertyId=(Id)VisName.Porperty_Id__c; &nbsp; &nbsp; &nbsp; &nbsp; VisitId=[select id,Name,Property__c from Visit__c where Property__c=:propertyId AND Name<:VisName.Visit__r.Name order by createddate desc limit 1]; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; if(VisitId!=null){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inspec=new Map<Id,Inspection_Sheet__c>([select id,Name,Date__c from Inspection_Sheet__c where Visit__c in(select id &nbsp;from Visit__c where id=:VisitId.id) ORDER BY Date__c]); &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SortType=[SELECT id,Name,Building__c,System_Location__c,System_Type__c,Type__c,createdDate,Pass__c,Fail__c,Inspection_Sheet__r.Date__c FROM System_Type__c WHERE Inspection_Sheet__c in:(Inspec.keyset()) order by Inspection_Sheet__r.Date__c desc]; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; system.debug('>>>>>'+SortType); &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for(System_Type__c Sys: SortType){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(systemType.containskey(Sys.Inspection_Sheet__c)){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; systemType.get(Sys.Inspection_Sheet__c).add(Sys); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; systemType.put(Sys.Inspection_Sheet__c,new List<System_Type__c>{Sys}); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; }  }