Thanks for that. Works great.

However, I have to say, these are the kinds of things that should be easier to accomplish. Like maybe you should have the ability to have some variable that represents the data that goes in a particular cell, in addition to looking at the whole row. I dunno. Seems like you have to go through a lot to get the simple things you need *sometimes*.

Other things are a breeze :)

My code looks like this, btw:
package
{
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridItemRenderer;
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.Text;
import mx.controls.dataGridClasses.DataGridColumn;

public class MarkyItemRenderer extends DataGridItemRenderer
{
        public function MarkyItemRenderer()
        {
                super();
        }
        
        private var lastUID:String;     // the last thing we rendered
        
        
        
        override public function set data(value:Object):void
        {
                super.data = value;

                if (listData && listData.uid != lastUID)
                {
                        
                        // this is how you get at the particular "column" of 
data
                        var dgListData:DataGridListData = listData as 
DataGridListData;
                        var dataGrid:DataGrid = dgListData.owner as DataGrid;
                        var column:DataGridColumn = 
dataGrid.columns[dgListData.columnIndex];
        
                        // checking the property to see if we should style the 
text
                        if (value.is_admin == true) {
                                styleName = "adminStyle";
                        }
                        
                        //setting the text
                        text = data[column.dataField];
                        lastUID = listData.uid;
                }
        }

}
}

On Apr 18, 2007, at 12:29 PM, Alex Harui wrote:


If you implemet IDropInListItemRenderer, you will get passed the column you are rendering.

There are examples on my blog http://blogs.adobe.com/aharui/ item_renderers/ that you might find useful

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mark McCray
Sent: Wednesday, April 18, 2007 8:41 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] itemRenderer simple question

Hi there,

I'm writing a simple itemRenderer that i want to use across multiple
columns.
The itemRenderer will look at a property of the data object that it
receives to tell what style should be applied to the <mx:Text> object
that will display the data.
That part is easy.
But how do I set the "text" value of the <mx:Text> to whatever the
value of that column is?
(does that make sense?)

For example, if the column I'm in has a dataField property of
"email", I want the itemRenderer to display the value of email --
without having to write data.email in the itemRenderer.

What we're really trying to do is to apply a style to the text of an
entire row if one of the row's properties is true.
Thanks,
mark





Reply via email to