Hi Joan, thanks for your reply. It works pretty fine. I noticed something I didnt know. It seems that when you set the dataField property of a DataGridColumn, only that particular data is passed to the itemRenderer. But with your example, I realized the the ENTIRE value object is passed to each DataGridColumn's itemRenderer, what allows you to create a cell that combines more than one data field and so on. Thanks again =)
On 6/13/07, Joan Lafferty <[EMAIL PROTECTED]> wrote:
You will need to use a custom itemRenderer that overrides the set data function for the columns that you want to change. Here is an example of one that looks at the column "qty" to determine what the color of the text in the cell is: package { import mx.controls.Label; public class CustomComp extends Label { override public function set data(value:Object):void { if(value != null) { super.data = value; if(value.qty < 10) { setStyle("color", 0xFF0000); } else { setStyle("color", 0x000000); } } } } } Here is a DataGrid that might use this: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="600" height="600" xmlns="*" > <mx:Script> <![CDATA[ [Bindable] public var DP:Array = [{item: 'Ice Cream', qty: 4}, {item: 'Cones', qty: 21}, {item: 'Sandwich', qty: 14}, {item: 'Malt', qty: 1}]; ]]> </mx:Script> <mx:DataGrid id="myDatagrid" rowHeight="50" dataProvider="{DP}"> <mx:columns> <mx:Array> <mx:DataGridColumn dataField="item" itemRenderer="CustomComp" /> <mx:DataGridColumn itemRenderer="CustomComp" dataField="qty" /> </mx:Array> </mx:columns> </mx:DataGrid> </mx:Application> Good luck. Joan ------------------------------ *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *André Rodrigues Pena *Sent:* Wednesday, June 13, 2007 7:39 AM *To:* flexcoders@yahoogroups.com *Subject:* [flexcoders] Datagrid itemRenderer Hi all, I want the color of the text in a particular cell of a Datagrid, modify depending on the value of another cell, in the same record. I thought of some function like labelFunction but it only applies to the text. I need to modify the properties of the Label, that I think is the default itemRenderer. I could create a custom itemRenderer too but I thought there could be an easier way to do that. any tips are welcome. -- André Rodrigues Pena
-- André Rodrigues Pena