Hi Angelo,
You're close. You'll need to declare the event in the DataGrid. A
simple subclass should do the trick. This way you can add the event
listener in mxml too:
package myPackage
{
import mx.controls.DataGrid;
[Event( name="myTest", type="flash.events.Event" )]
public class MyDataGrid extends DataGrid
{
}
}
-TH
--- In [email protected], Angelo Anolin <angelo_ano...@...>
wrote:
>
> I have written the following scripts, and yet this does not seem to
work.
>
> in my MXML file (main)
>
> private function myDataGrid_CreationComplete() :void
> {
> myDataGrid.addEventListener('myTest', myTesting);
> }
>
> private function myTesting() :void
> {
> Alert.show('This event should have been called!');
> }
>
>
> in my datagrid, i have declared
> creationComplete="myDataGrid_CreationComplete()"
>
> In my itemrenderer, I have placed a code :
>
> override protected function clickHandler(event:MouseEvent) :void
> {
> dispatchEvent(new Event('myTest', true));
> }
>
> For some reason, this does not seem to work. From what I have read
mostly, this
> should be able to do the trick.
>
> Any input and ideas appreciated. Thanks..
>
>
>
> ________________________________
> From: Angelo Anolin angelo_ano...@...
> To: [email protected]
> Sent: Tue, 17 August, 2010 8:34:07
> Subject: Re: [flexcoders] Re: Method for a Datagrid Button
Itemrenderer
>
>
> Hi Don,
>
> Thanks for the reply.
>
> I do am able to do the same using an in-line itemrenderer.
>
> But right now, my itemrenderer is an external AS file.
>
> So I declare my MXML like:
>
> <mx:DataGridColumn
> id="dgActionColumn" width="100" visible="true"
itemRenderer="myButtonItemRenderer"
> />
>
> Where myButtonItemRenderer is an external AS file which extends the
button.
>
> Now, where I declare the datagrid, I am writing a function which I
need to wire
> up to the itemrenderer so that on the click of the button, that method
is
> dispatched.
>
> Thanks.
>
>
>
>
>
> ________________________________
> From: fusionpage fusionp...@...
> To: [email protected]
> Sent: Tue, 17 August, 2010 8:29:11
> Subject: [flexcoders] Re: Method for a Datagrid Button Itemrenderer
>
>
> I typically use code like this to call a method in the parent MXML
page that
> contains the dataGrid...
>
> <mx:AdvancedDataGridColumn width="80" headerText="Launch"
> dataField="contentURL">
> <mx:itemRenderer>
> <mx:Component>
> <mx:Button label="Launch" click="parentDocument.goDownload();"/>
> </mx:Component>
> </mx:itemRenderer>
> </mx:AdvancedDataGridColumn>
>
> Don
>
> --- In [email protected], Angelo Anolin angelo_anolin@ wrote:
> >
> > I know someone has encountered this before.
> >
> > Better to rephrase this one I guess.
> >
> > I have an MXML file, where I have a method. In that MXML file, I
have a
> > datagrid, where one of the columns, I created an external
itemrenderer. The
> > itemrenderer is a button. When I click that button, I want that
button to call
> >
> > the method in the MXML file (so that I could re-use the button on
other
> > datagrids).
> >
> > Thanks.
> >
> >
> >
> > ________________________________
> > From: Angelo Anolin angelo_anolin@
> > To: [email protected]
> > Sent: Mon, 16 August, 2010 13:54:33
> > Subject: [flexcoders] Method for a Datagrid Button Itemrenderer
> >
> >
> > Hi Flexcoders,
> >
> > I have a datagrid and an button itemrenderer named btnRenderer.as
> >
> > I have set this button as an itemRenderer in one of my datagrid
columns.
> >
> > <mx:DataGridColumn id="dgColCancel" width="100"
itemRenderer="btnRenderer" />
> >
> > I need to respond to an click event on button, passing some of the
value from
> > the dataProvider attached to the datagrid.
> >
> > Should I place my codes on the mxml file where my datagrid is
declared? How
> > would the btnRenderer know that the method is called?
> >
> > Thanks.
> >
>