colorRenderer.mxml <mx:VBox
xmlns:mx="http://www.macromedia.com/2003/mxml"
mouseDown="updateColor()" width="100%"> <mx:Script> <![CDATA[ var getCellIndex:Function; var listOwner:MovieClip; var colorCount:Number = 0; static var colors:Array = [0xff0000,
0x00ff00, 0x0000ff]; function setValue(str:String,
item:Object, sel:Boolean){
this.setStyle("backgroundColor", item.cellBackColor) myLabel.text =
str; } function updateColor() {
listOwner.dataProvider.editField(getCellIndex().itemIndex,
"cellBackColor", colors[colorCount++ % 3]); } ]]> </mx:Script> <mx:Label id="myLabel"
/> </mx:VBox> Note that the clicking only works over the
Label the first time but the whole cell once the color has changed once.
I’ll let you debug it further… From: Hi, Can anyone send me some sample code / point to some sample
code to change the background color of a cell in a datagrid when the cell is
clicked. I have tried writing a custom cellRenderer for this but with
no luck. class MyCellRenderer extends UIComponent function MyCellRenderer()
listOwner.dataProvider.editField(getCellIndex().columnIndex,
"backgroundColor", 0xCC66FF); Thanks in advance,
|
Title: changing background color of a cell in datagrid