Colour in Cell dependant on a value

Hi All,
In the list a way to change the colour of a cell dependant on its value. I have a table called BOOKINGS with a field called STATUS in it. I would like to change the cell colour as follows when it is Listed.BOOKINGS.STATUS = New - colour of cell RED
BOOKINGS.STATUS = Pending - colour of cell ORANGE
BOOKINGS.STATUS = Confirmed - colour of cell GREENRegards
Martyn

Use Row_Rendered server event. Read “Server Events and Client Scripts” in the help file.

Perfect solution Many thanks - here is some code nothing fancy could have used the “Switch” instead of 4 IF’s to help anyone who needs this function

// Row Rendered event
function Row_Rendered() {
    // To view properties of field class, use:
    //var_dump($this-><FieldName>);  
    
       if ($this->status->ViewValue=="New") { 
$this->status->CellAttrs["style"] = "color:#FFFFFF; background-color:#FF0000";    
}
    
     if ($this->status->ViewValue=="Confirmed") { 
$this->status->CellAttrs["style"] = "color:#FFFFFF; background-color:#008000";    
}                                             
    
  if ($this->status->ViewValue=="Pending") {         
$this->status->CellAttrs["style"] = "color:#FFFFFF; background-color:#FFA500";    
}   
 
        
          if ($this->status->ViewValue=="Cancelled") { 
$this->status->CellAttrs["style"] = "color:#FFFFFF; background-color:#0000FF";    
}   
  
}

the code works, but I have a problemif I use a field in the table with a space, it is an error.
how can I do? (I know you that I make a mistake using the spaces)

// Row Rendered event
function Row_Rendered() {
	// To view properties of field class, use:
	//var_dump($this-><FieldName>);

 if ($this->Area Rivervata->ViewValue=="y") { 
$this->Area Riservata->CellAttrs["style"] = "color:#FFFFFF; background-color:#0000FF";
}
}

error:Parse error: syntax error, unexpected ‘Rivervata’ (T_STRING) in C:\xampp\htdocs\personale\pc_traduzioniinfo.php on line 1118

You may actually check from the generated code in the related script files. Usually, the space character in a field name will be removed. So, your code above should be:

if ($this->AreaRivervata->ViewValue=="y") {
    $this->AreaRiservata->CellAttrs["style"] = "color:#FFFFFF; background-color:#0000FF";
}

ERRORNotice: Undefined property: cpc_traduzioni_list::$AreaRivervata in C:\xampp\htdocs\personale\pc_traduzioniinfo.php on line 1118
Notice: Trying to get property ‘ViewValue’ of non-object in C:\xampp\htdocs\personale\pc_traduzioniinfo.php on line 1118

The $this->AreaRiservata in your code is null. You better check the generated code to find the correct variable name of the field, or you may see Tools → Database, Table and Field Variable Names.

If I am not mistaken, this code:

if ($this->AreaRivervata->ViewValue=="y") {
    $this->AreaRiservata->CellAttrs["style"] = "color:#FFFFFF; background-color:#0000FF";
}

will cause an notice error as follows:
Notice: Undefined property: cpc_traduzioni_list::$AreaRivervata in C:\xampp\htdocs\personale\pc_traduzioniinfo.php on line 1118So, your code above should be:

if ($this->AreaRiservata->ViewValue=="y") { // it should be AreaRiservata instead of AreaRivervata
    $this->AreaRiservata->CellAttrs["style"] = "color:#FFFFFF; background-color:#0000FF";
}

Spaces are replaced by underscores. The code should be:

if ($this->Area_Riservata->ViewValue=="y") { // it should be Area_Riservata instead of AreaRivervata
    $this->Area_Riservata->CellAttrs["style"] = "color:#FFFFFF; background-color:#0000FF";
}

To check variable names, see Database, Table and Field Variable Names.