Friday, May 04, 2007

Flex 2 Inline Item Renderer Tip

I stumbled upon an unknown property as I was trying to use an Inline Item Renderer on my DataGrid Columns. If you use the <mx:component> tag with your inline item renderer and try to have your component call an event in your main application you will get a nasty "Access to undefined method blah blah". This is because your Inline Item Renderer is unaware of what exists in your main application. But you can use the outerDocument property to access event handlers in you main application.

<mx:itemRenderer>
<mx:Component>
<mx:VBox >
<mx:Button label="Remove" click="outerDocument.remove()"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>

11 comments:

Anonymous said...

Is there something you need to do to use outerDocument? I always get undefined property outerDocument

Gurufaction said...

You must be within a mx:component tag to access the outerDocument property.

Satish said...

hello Guru.

this is about the paging live-grid example. That was wicked cool.

Can we work on building a Live-Grid Control with Flex? Similar to the OpenRico LiveGrid. http://openrico.org/demos/livegrid

thanks
Satish
Boston

Satish said...

hello Guru.

this is about the paging live-grid example. That was wicked cool.

Can we work on building a Live-Grid Control with Flex? Similar to the OpenRico LiveGrid. http://openrico.org/demos/livegrid

thanks
Satish
Boston

Anonymous said...

how to use itemRenderer using actionscript3.0? (no mxml)

Gurufaction said...

Using itemRenderer with actionscript 3 you must use the ClassFactory.

Anonymous said...

This issue made me cry, thanks for postiing

Alastair said...

I was also going nuts with this, thanks

Anonymous said...

thanks!!! your safe my life!!!

Ari said...

How to access the reverse way ?

I mean if I need to access item renderer id from main application. How to do this ?

Anonymous said...

Make sure the method you're trying to call through outerDocument is public, otherwise, it will still complain.