Hi,

 Here is a small sample code... I am not even using Title window anymore

an application with datagrid with a button cell renderer. The button
on click dispatchs a event and I am trying to catch it in the
application which is not working.

testMain.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";  xmlns="*">
<mx:Script>

function confirm() {
dg.addEventListener("confirmEvent", this);
}

function confirmEvent(event) {
mx.core.Application.alert("in listener ");
myLabel.text="Button clicked: "+event.buttonClicked;
}
</mx:Script>

<mx:Model id="employeeModel" source="employees.xml"/>
<mx:Label id="myLabel"/>
<mx:DataGrid id="dg" height="100%" width="100%"
dataProvider="{employeeModel.employee}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="fName" headerText="First Name"/>
<mx:DataGridColumn columnName="lName" headerText="Last Name"/>
<mx:DataGridColumn columnName="location" headerText="Location"/>
<mx:DataGridColumn columnName="fName" headerText="Action"
cellRenderer="FindMrRequestButtonRenderer"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Application>

FindMrRequestButtonRenderer.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Button xmlns:mx="http://www.macromedia.com/2003/mxml"; label="Ok"
click="editRow(event)">
<mx:Metadata>
[Event("confirmEvent")]
</mx:Metadata>

<mx:Script>
var rowData : Object;
var getDataLabel : Function;
var listOwner : Object;
<![CDATA[
function setValue( str:String, item:Object, sel:Boolean ) {
this.visible = item != undefined;
if(item !=undefined){
        rowData = item[getDataLabel()];
}
}

function editRow(event){
mx.core.Application.alert("Order Added ");
listOwner.dispatchEvent({type:'confirmEvent', buttonClicked: 'yes'});
}
]]>
</mx:Script>
</mx:Button>


employees.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<allEmployees>
<employee>
<fName>
Clare
</fName>
<lName>
DuPre
</lName>
<location>
Paris
</location>
</employee>
<employee>
<fName>
David
</fName>
<lName>
Green
</lName>
<location>
San Francisco
</location>
</employee>
</allEmployees>


Even here I am unable to see the second alert. 

Should I not add the listener to the datagrid, to what and how should
I do it?

Rajesh J





------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hegl2g5/M=362131.6882499.7825260.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1123732104/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

--
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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to