2

I have a spark list control whose data is rendered using an itemrenderer. Basically the Item renderer lays out the data within a Panel.

The Panel has a LinkButton, which when clicked needs to pass an Id to the parent application. In the parent application I have a function that dispatches a custom event to its parent. I want to know how to call this function from the ItemRenderer.

I tried using parentDocument.outerfunction etc but it throws an error..

Any clues ?

Wade Mueller
  • 6,059
  • 17
  • 19
Lin
  • 273
  • 4
  • 21

5 Answers5

4

I would have your item renderer dispatch a custom event that contains your Id, making sure that your event bubbles. Then in the parent application listen for that event and call the appropriate function. Hope that helps.

Wade Mueller
  • 6,059
  • 17
  • 19
  • Yes i tried dat too... in my item renderer, I have registered my custom event. On the click of the linkbutton, i create an instance of the evnt and then dispatch it. However I have no clue how to handle it in the parent application. .. could u show me some code that will explain this ? – Lin Jan 25 '11 at 06:44
  • 1
    in your itemRenderer : new CustomEvent(CustomEvent.CUSTOM, true); in your parent : addEventListener(CustomEvent.CUSTOM, customHandler) – Florian F Jan 25 '11 at 07:53
  • 1
    Or, if you don't want to use bubble : in your itemRenderer : new CustomEvent(CustomEvent.CUSTOM); in your parent : addEventListener(CustomEvent.CUSTOM, customHandler, true) – Florian F Jan 25 '11 at 07:54
0

If I understand well you can try to call from the item renderer this.parentApplication or this.parent.parent.

ivy
  • 210
  • 1
  • 2
  • 14
0

The best way is to create a custom event and bubble .. and add an event listener for that event in parent document..

Lin
  • 273
  • 4
  • 21
0

this is working I have test parentcomponent(this.owner.parent).function...owner is list and parent is the component in which list is placed e-g InvitationList(this.owner.parent).invitationAccepted(persist); type cast the this.owner.parent to your parentclass

-1

If you were using PureMVC, you could send a notification that the receiver would handle and perform the needed work. This is similar to firing a custom event and receiving it in the parent.

jrsjr
  • 74
  • 5