Thank you Alex and Amy for clarification.
Angelo ________________________________ From: Alex Harui <[email protected]> To: "[email protected]" <[email protected]> Sent: Fri, 16 April, 2010 22:51:20 Subject: Re: [flexcoders] Re: Reuse a LabelFunction Amy is saying you could write your function like this: private function labelFunctionTest( itm:Object, col:DataGridColumn) :String { return df.format(itm[ col.dataField] ); } Which is correct and probably the easiest way to go. If you want to subclass you would do something like this: public class AngeloDataGridColum n extends DataGridColumn { public function AngeloDataGridColum n() { labelFunction = labelFunctionTest; } private function labelFunctionTest( item:Object, col:DataGridColumn) :String { return owner.document. df.format( item[dataField] ); } } By subclassing you don’t have to assign the labelFunctions to the columns that need them. On 4/16/10 2:12 PM, "Angelo Anolin" <angelo_anolin@ yahoo.com> wrote: >> >> >> > >Hi Alex, >> >>Appreciate if you could show a little example. >> >>Thanks. >> >>Angelo > > ________________________________ From:Alex Harui <aha...@adobe. com> >To: "flexcod...@yahoogro ups.com" <flexcod...@yahoogro ups.com> >Sent: Fri, 16 April, 2010 12:29:57 >Subject: Re: [flexcoders] Re: Reuse a LabelFunction > >> >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" <valdhorlists@ embarqmail. com> wrote: > > > >>>> >>>> >>>> >> >>>>If it were me, I would use an item renderer. >> >>>>--- In flexcod...@yahoogro ups.com <mailto:flexcoders% 40yahoogroups. com >>>><mailto:flexcoders% 40yahoogroups. com> > , Angelo Anolin <angelo_anolin@ >>>>...> 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 <amyblankenship@ ...> >>>>> To: flexcod...@yahoogro ups.com <mailto:flexcoders% 40yahoogroups. com >>>>> <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

