FLEX中使用itemRenderer调用父页面的方法使用关键字outerDocument
调用的父页面方法必须是PUBLIC声明的方法
调用的父页面方法必须是PUBLIC声明的方法
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:local="*"
layout="absolute" >
<mx:Script>
<![CDATA[
import mx.controls.CheckBox;
import mx.controls.Alert;
[Bindable]
private var dp:Array = [
{idx:1, names: "test1", sex: "b" },
{idx:2, names: "test2", sex: "g" }
];
public function doSelect(o:Object):void
{
Alert.show("选择了"+o.idx+"/"+o.names+"/"+o.sex);
}
]]>
</mx:Script>
<mx:DataGrid id="dg1" dataProvider ="{dp}">
<mx:columns>
<mx:DataGridColumn width="20" headerText="" >
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox change=" {outerDocument.doSelect(data as Object)} " />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="names" dataField="names" width="200" />
<mx:DataGridColumn headerText="sex" dataField="sex" width="300" />
</mx:columns>
</mx:DataGrid>
</mx:Application>