Close…..few questions. And I guess I should have clarified, but I’m using Flex 2 at the moment. I’ve narrowed it down so I have 0 errors, but nothing is calling my listener :-/


1) what is listOwner?

2) I’m assuming all those Delegate.create are for Flex 1.5
3) how would I set bubbles:true in Flex 2?

 


…actually this would just be easier if I showed you what I’m attempting, it’s pretty small…remember Flex 2. You can laugh at me if it’s wrong
J

In main mxml file:
public function AFTAComplete() {

AFTAsDG.addEventListener("refreshService", refreshAFTA);   

}

public function refreshAFTA() {

myAFTAService.url = "">"AFTAs.cfm?show=true";

CursorManager.setBusyCursor();

myAFTAService.send();  

}

 

 

Lower in the main file:

<mx:Metadata>

 [Event("refreshService")]

</mx:Metadata>

<mx:DataGrid creationComplete="AFTAComplete()" id="AFTAsDG" width="100%" height="95%" dataProvider="{myAFTAService.result.query.row}">

<mx:columns>

<mx:Array>

<mx:DataGridColumn headerText="CTRL" cellRenderer="MenuButton" width="45" textAlign="center"/>

</mx:Array>

</mx:columns>

</mx:DataGrid>

     

 

In MenuButton.mxml:

<mx:HBox xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" height="17" width="45" horizontalAlign="center">

      <mx:Script>

            <![CDATA[

            import flash.events.Event;

                 

            public function deleteDev() {

                  if(dataObject.additional == "no") {

                        Alert.show("Sorry, this is the main developer","Error",Alert.OK);

                  } else {

                        Alert.show("Deleting: "+dataObject.INTRA_USERID,"Event",Alert.OK);

                  }

                  deleteBtn.dispatchEvent(new Event('refreshService'));

            }

            ]]>

      </mx:Script>

      <mx:Button id="deleteBtn" label="- " width="17"  height="17" textAlign="right" click="deleteDev()"/>

</mx:HBox>

 

 

Least right now I’m not getting errors, but nothing is calling refreshAFTA

_________________________________________

Jonathan Miranda

Flexible Master of the Web

"In the game of chess, it's important to never let your opponent see your pieces."

 

From: [email protected] [mailto:[email protected]] On Behalf Of JesterXL
Sent: Tuesday, January 31, 2006 11:39 AM
To: [email protected]
Subject: Re: [flexcoders] DataGrid Renderer and referencing back

 

Here's the basic steps for Flex 1.5:

- put a button in your cellrenderer

- if ActionScript, register for the click event, and provide a click function delegate in the cell renderer

- if MXML, point click event to a event handler function in the cellrenderer

- in your event handler for the button's click, have it dispatch an event

 

- in your DataGrid container, register for the custom click event; can only do this via code since you made up the event name, and DataGrid.as won't have your event in the metadata

 

So, some psuedo code for your cellrenderer:

 

var ref:Button = Button(createChild(Button));

ref.addEventListener("click", Delegate.create(this, onClick));

 

function onClick(event:Object):Void

{

    listOwner.dispatchEvent({type: "makeNameForThisEventMeaningful", target: listOwner, bubbles: true});

}

 

And, some code for your container:

 

function onCreationComplete()

{

    yourDataGrid.addEventListener("makeNameForThisEventMeaningful", Delegate.create(this, onClicked));

}

 

function onClicked(event:Object):Void

{

    // button was clicked in datagrid, do HTTPService.send stuff

}

 

Make sense?

 

 

 

----- Original Message -----

Sent: Tuesday, January 31, 2006 1:13 PM

Subject: RE: [flexcoders] DataGrid Renderer and referencing back

 

Hey jester, thanks for the reply…but could give a real basic example of this?

I’m having issues with “bubbling”….I found a semi-example on CFlex and working with that so far using…

this.dispatchEvent(someEventObject);

 

So would I need someEventObject in both the application mxml and the renderer mxml so that it would call both?

 

_________________________________________

Jonathan Miranda

Flexible Master of the Web

"In the game of chess, it's important to never let your opponent see your pieces."

 

From: [email protected] [mailto:[email protected]] On Behalf Of JesterXL
Sent: Tuesday, January 31, 2006 10:50 AM
To: [email protected]
Subject: Re: [flexcoders] DataGrid Renderer and referencing back

 

You can dispatch an event that bubbles in your cellrenderer, and your main app can catch this event, and then resend the HTTPService.  Since the event is not internal to DataGrid's metadata, you can only subscribe via code.

 

----- Original Message -----

Sent: Tuesday, January 31, 2006 12:29 PM

Subject: [flexcoders] DataGrid Renderer and referencing back

 

I have a custom cellRenderer which has a button in it…and when that button is pressed, I want to force the datagrid to resend it’s HTTPService to get an update. How can I reference my HTTPService in the main app, when my custom cellRenderer is in a separate mxml file?

 

_________________________________________

Jonathan Miranda

Flexible Master of the Web

 




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to