If it were me, I would subclass DataGridColumn and add the labelfunction to the 
subclass.  Then it has the DGC’s context like dataField to work with.


On 4/16/10 7:40 AM, "valdhor" <[email protected]> wrote:






If it were me, I would use an item renderer.

--- In [email protected] <mailto:flexcoders%40yahoogroups.com> , 
Angelo Anolin <angelo_ano...@...> wrote:
>
> Hi Amy,
>
> But as you can see in the function, I am specifying the Datafieldname from 
> the object which was passed.
>
> How can I make it more generic so that I can re-use it in other datagrid 
> columns?  I hope you could provide some samples. thanks.
>
> Angelo
>
>
>
>
> ________________________________
> From: Amy <amyblankens...@...>
> To: [email protected] <mailto:flexcoders%40yahoogroups.com>
> Sent: Fri, 19 March, 2010 9:13:38
> Subject: [flexcoders] Re: Reuse a LabelFunction
>
> Â
>
>
> --- In flexcod...@yahoogro ups.com, Angelo Anolin <angelo_anolin@ ...> wrote:
> >
> > Hi FlexCoders,
> >
> > I have created a labelfunction which I use in my datagrid to format the 
> > display value.
> >
> > <mx:DateFormatter id="df" formatString= "DD/MM/YYYY" />
> >
> > And this is the AS function
> > private function labelFunctionTest( itm:Object, col:DataGridColumn) :String
> > {
> > Â Â Â  return df.format(itm. DataFieldNamefor Col1);
> > }
> >
> > Is there a way so that I could reuse the same label function to other 
> > datagrid columns?  As you can see from the script above, I am only using 
> > the function to Col1 for the datagrid.  How would I be able to specify the 
> > datafield if I am going to reuse the same with other datagrid columns?
>
> That is what the DataGridColumn parameter is for. Look at its dataField 
> property.
>
> HTH;
>
> Amy
>






--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to