set the background color of the cell of a data grid to yellow when the value of a cell is greater than 6

advertisements

Iam using flex 3.5 . I want to set the back ground color of cell in a datagrid to yellow when the data in it is more than 6 .


Create a custom renderer and test the value when the data property is set:

override public function set data(value:Object):void
{
  super.data = value; 

  if(data > 6)
    setStyle("backgroundColor", 0xFFFF00);
  else
    setStyle("backgroundColor", 0xFFFFFF);
}

Remember that you need to revert the color if the test fails since Lists reuse renders (you would get random yellow backgrounds if you dont).