There are many ways to do what you want... here are a couple:

1) Probably the simplest: use labelFunction on the column <http://livedocs.adobe.com/labs/flex/3/langref/mx/controls/dataGridClasses/DataGridColumn.html#labelFunction>.

2) My preferred approach for code that has any complexity: Parse your data in ActionScript objects and place then in an ArrayCollection, then bind your grid to the ArrayCollection. Once your data is in Objects there is no end to the flexibility. For instance, if you have a class MyLabel that has a Boolean member variable like _isActive... you can add a method like the following which would allow you to bind your column to the "activeLabel" property.

public function get activeLabel():String
{
   var ret:String = Constants.TRUE_STRING;
   if(!_isActive)
   {
      ret = Constants.FALSE_STRING;
   }
return ret;
}

3) Custom item renderer: Probably overkill here

hth
Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com



captnjay_mobile wrote:

I'm still rather new to flex.. so forgive me if I'm not going about this
the right way.
I want to simply change the value of data within datagrid, based on some
criteria.
In this case, I have records coming back athat are either active or
inactive.

In the database these values are 0' and 1's, but I'd like to display
either "Active" or "Inactive" instead.

Do I need to use a itemrenderer in this case? Or is there a simpler way?

When I run the code below, it doesn't likt the use of data.blnActive...

<mx:DataGridColumn headerText="Active?" dataField="blnActive">
<mx:itemRenderer>
<mx:Component>
<mx:Label id="activeLabel"
text="">
<mx:Script>
<![CDATA[

if(data.blnActive == 0)
{

activeLabel.text = 'False'
}
else
{

activeLabel.text = 'True'
}

]]>
</mx:Script>
</mx:Label>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>

Reply via email to