tags:

views:

25

answers:

1

I have a grid, when i click on the edit button it goes to edit page... but i need the value in the grid also to be passed to the page.

this.dispatchEvent(new DepManagementEvent(DepManagementEvent.EDIT_NAVI));

The above code lands in EDIT page... how can i move the values too.

My Parent Page code.

private function editForm():void {
       var event:DepManagementEvent = new DepManagementEvent("Edit Page",true);
       dispatchEvent(event);
      }

The Edit Page below....

public function init(event:DepManagementEvent):void {
     this.addEventListener(DepManagementEvent.EDIT_NAVI, onEditNavi); 
    }

    public function onEditNavi(event:DepManagementEvent):void {
     Alert.show("as");
    }

I am not getting the alert, when the page is navigated from the parent one.... on click. Also edit this code on how i can pass the variables too.

+2  A: 

Add a public var (called "navi" in the code below) to the DepManagementEvent that's of the same type as the item in the grid, then dispatch the event like this instead:

var event:DepManagementEvent = new DepManagementEvent( DepManagementEvent.EDIT_NAVI );
event.navi = grid.selectedItem;
dispatchEvent( event );

To listen to the event on the other side, you add an event listener for a function...

addEventListener( DepManagementEvent.EDIT_NAVI, onEditNavi);

private function onEditNavi( event:DepManagementEvent ):void
{
    // add logic here
}

Since you're in an itemRenderer, you can dispatch a bubbling event that will move up to the parent List/DataGrid and continue to bubble up to other parent views in the display hierarchy. When you create the event, pass the second argument ("bubbles") as true:

new DepManagementEvent( DepManagementEvent.EDIT_NAVI, true );
cliff.meyers
How to listen the event at the other end, also the edit button of the grid is in different page as an itemRenderer.
`function eventHandler(event:DepManagementEvent){trace(event.navi);}`
Amarghosh
listen to the button's click event in the class where item renderer is and dispatch this event from there.
Amarghosh
I added a few examples above.
cliff.meyers
Thanks for the examples, i still dont get