I have following problem. I need to be able to render the content of a cell "delayed" based upon the content of cell "DelaySeverity". However the following renderer (BackgroundComp) only renders the background of the cell itself.
How can I modify this class such that I can render the cell based upon the content from another column ?
ActionScript Code:
<mx:Array>
<mx:DataGridColumn dataField="id" headerText="Airline" />
<mx:DataGridColumn dataField="cancelled" headerText="Cancelled Flights (%)" />
<mx:DataGridColumn dataField="delayed" headerText="Delayed Flights (%)" />
<mx:DataGridColumn dataField="DelaySeverity" headerText="Delay" itemRenderer="BackgroundComp" />
</mx:Array>
ActionScript Code:
package {
import mx.controls.Label;
import mx.controls.dataGridClasses.*;
import mx.controls.DataGrid;
import flash.display.Graphics;
import mx.styles.StyleManager;
[Style(name="backgroundColor", type="uint", format="Color", inherit="no")]
public class BackgroundComp extends Label {
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var g:Graphics = graphics;
g.clear();
var grid1:DataGrid = DataGrid(DataGridListData(listData).owner);
if (grid1.isItemSelected(data) || grid1.isItemHighlighted(data))
return;
switch (data[DataGridListData(listData).dataField]) {
case (1): {
g.beginFill(0xDE0033);
g.drawRect(0, 0, unscaledWidth, unscaledHeight);
g.endFill();
break;
}
case (2): {
g.beginFill(0x51DEED);
g.drawRect(0, 0, unscaledWidth, unscaledHeight);
g.endFill();
break;
}
case (3): {
g.beginFill(0x7CFFE3);
g.drawRect(0, 0, unscaledWidth, unscaledHeight);
g.endFill();
break;
}
} // switch
} // override
} // class
} // package