@Tim:
Yeah, that's exactly what I ended up implementing.. I was just puzzled,
that's all really... :)

@Alex:
Hmm...  I tried to use the owner property without subclassing the
DataGridColumn with no success...
Maybe I'll try that.

Thanks a lot for all the responses!

Sefi


On Sun, Aug 24, 2008 at 5:56 AM, Alex Harui <[EMAIL PROTECTED]> wrote:

>    Note that, if you subclass the DataGrid and add your labelFunctions to
> the subclass, then the this pointer during the call is the datagrid and you
> can rummage through the column set all you want.
>
>
>
> Also note that, if you subclass DataGridColumn, as I often did in the
> examples on my blog (blogs.adobe.com/aharui), the this pointer is the
> column and you can use its owner property to get back out to the DataGrid
> and the rest of the columns.
>
>
>
> I haven't been following the thread too closely, so I may be out of
> context.
>
>
>  ------------------------------
>
> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Tim Hoff
> *Sent:* Saturday, August 23, 2008 10:22 AM
> *To:* [email protected]
> *Subject:* [flexcoders] Re: DataGridColumn trouble...
>
>
>
> Sefi,
>
> If you really wanted to try to get at the calculated values in another
> column, in the same row, you would have to use an itemRenderer.  Because an
> itemRenderer implements IDropInListItemRenderer, it has access to the
> listData property.  This property contains the rowIndex and the columnIndex
> of the cell that it is rendering.  While it would clearly be a pain in the
> ass, you could use the rowIndex property to locate and reference the other
> itemRenderer values in the same row, for the columns that are desired.  My
> opinion is that for something simple like this, it would be overkill and
> probably require more processing overhead for locating the other
> itemRenderers.  Instead, this is the solution that I would use.  Don't bang
> too hard. :-)
>
> *private* *function* calculateStartValue(item:Object):Number
> {
> *     var* startValue:Number = Number(item.start); *// complex calcs here
> **     return* startValue;
> }
>
> *private* *function* startLabelFunction(item:Object,
> column:DataGridColumn):Number
> {
> *     return* calculateStartValue(item);
> }
>
> *private* *function* calculateEndValue(item:Object):Number
> {
> *    var* endValue:Number = Number(item.end); *// complex calcs here
> **    return* endValue;
> }
>
> *private* *function* endLabelFunction(item:Object,
> column:DataGridColumn):Number
> {
> *    return* calculateEndValue(item);
> }
>
> *private* *function* diffLabelFunction(item:Object,
> column:DataGridColumn):Number
> {
> *    return* calculateEndValue(item) - calculateStartValue(item);
> }
>
> <mx:DataGrid dataProvider="{ myArrayCollection }">
>      <mx:columns>
>           <mx:DataGridColumn headerText="Start" labelFunction="
> startLabelFunction"/>
>           <mx:DataGridColumn headerText="End" labelFunction="endLabelF!
> unction"/>
>           <mx:DataGridColumn headerText="Diff" labelFunction="
> diffLabelFunction"/>
>      </mx:columns>
> </mx:DataGrid>
>
> -TH
>
> --- In [email protected], "Sefi Ninio" <[EMAIL PROTECTED]> wrote:
> >
> > Exactly what I was thinking...
> >
> > So, to make sure I get this straight - There is no way to get to the
> other
> > DataGridColumns from the DataGridColumn passed to it's labelFunction.
> >
> > There is no getting around to making the same calculation for multiple
> > column except for keeping an external map (at least the size of the grid
> -
> > which chould be quite big) for the calculations results. This, of course,
> is
> > a mess. More so when you need to update the map when the dataProvider
> > changes...
> >
> > Ugh... Coding in Flex is a real joy, but every now and then I find myself
> > banging my head against the wall...
> >
> > Sefi
> >
> > On Sat, Aug 23, 2008 at 3:20 AM, mknuttall [EMAIL PROTECTED] wrote:
> >
> > > Because then it wouldn't be a VO. :)
> > >
> > >
> > > --- In [email protected] <flexcoders%40yahoogroups.com>,
> "Tracy
> > > Spratt" tspratt@ wrote:
> > > >
> > > > If you are usign VOs, why not just add properties and have the VO do
> the
> > > > calculation internally, and forget the labelFunctions entirely?
> > > >
> > > > Tracy
> > > >
> > >
> > >
> > >
> >
>
>  
>

Reply via email to