You will need to override the data setter

override public function set data( value:SomeType):void
{
    if( value != null)
   {
        text = data.somePropertyToGetTextFrom;
   }
}

This overcomes your timing issue via the nullity check.

I'd mozzy on over to Alex Hurai's blog for some talks on things like this.
Oh, equally as good and mayb emore directed, check out Peter Ent's blog.
He's been running a series on itemRendereres

DK

On Mon, Oct 6, 2008 at 3:52 PM, Greg Morphis <[EMAIL PROTECTED]> wrote:

> I have an application that retrieves data via a remoteobject call to a
> CFC and then populates a datagrid.
> I need to use an itemRenderer on the datagridcolumn but the data isnt
> there yet when the datagrid initializes..
> So how do I make the datagrid wait?
>
> in the index.mxml file I call the even that populates the
> arraycollection, I also include the view that is the datagrid..
>
> <!-- happens on creationComplete -->
> public function initMe():void {
>        var evt:CairngormEvent = new CairngormEvent(
> MyControl.EVENT_LOAD_DATA );
>        CairngormEventDispatcher.getInstance().dispatchEvent(evt);
> }
>
> then further down in the index.mxml
> <view:mainPage width="100%" height="70%" title="Foo App" />
>
> in the mainPage view I have my datagrid
> Here's my DG call:
>
>
>
> <mx:DataGrid id="dg" width="100%"
> height="100%"  dataProvider="{MyModel.getInstance().fooAC}"
> click="clickHandler(event);"
> dataTipFunction="buildToolTip">
> <mx:columns>
> ....
>        <mx:DataGridColumn dataField="amount"
>                        headerText="Amount:"
>                        textAlign="right"
>                        headerStyleName="centered"
>                        itemRenderer="com.renderers.PriceLabel" />
>
>
> </mx:columns>
> </mx:DataGrid>
>
> The data loads fine in the DataGrid but my custom itemRenderer which looks
> like
> package com.renderers {
>    import mx.controls.Label;
>    import mx.controls.listClasses.*;
>    import mx.controls.Alert;
>
>    public class PriceLabel extends Label {
>
>        override protected function
> updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
>            //super.updateDisplayList(unscaledWidth, unscaledHeight);
>                        //Alert.show(data.toString());
>
>        }
>    }
> }
>
> doesnt work.. it returns a null error when referencing data.*anything*..
>
> Any ideas would be great I'm racking my brain on this and it's getting
> the best of me!
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5502
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.37

Reply via email to