<?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" width="400" height="320" fontSize="14" title="添加站点" showCloseButton="true" close="CloseWnd()"> <mx:Script> <!--[CDATA[ import mx.events.CloseEvent; import mx.managers.PopUpManager; import Custom.*; [Bindable] public var platform:XML; public var site:Array = new Array(); private function Submit():void { dispatchEvent(new CustomEvent(Constant.Basic_busSite, site)); CloseWnd(); } public function CloseWnd():void { PopUpManager.removePopUp(this); } public function ChooseItem(selected:Boolean,sID:String):void { if(selected) { site.push(sID); } else { for(var i:int=0; i<site.length; i++) { if(site[i] == sID) { site.splice(i,1); } } } trace(site) } ]]--> </mx:Script> <mx:DataGrid id="dgPlatform" width="100%" height="100%" dataProvider="{platform.children()}"> <mx:columns> <mx:DataGridColumn headerText="站点编号" dataField="id"/> <mx:DataGridColumn headerText="站点名称" dataField="name"/> <mx:DataGridColumn headerText="地理位置" dataField="pos"/> <mx:DataGridColumn headerText="备注" dataField="remark"/> <mx:DataGridColumn headerText="勾选" width="80"> <mx:itemRenderer> <mx:Component> <mx:CheckBox label="选择" click="outerDocument.ChooseItem(this.selected,data.id)"/> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> <mx:ControlBar> <mx:Spacer width="60%"/> <mx:Button label="OK" click="Submit()"/> <mx:Button label="Cancel" click="dispatchEvent(new CloseEvent(CloseEvent.CLOSE))"/> </mx:ControlBar> </mx:TitleWindow> 备注: 在itemRenderer内部提用方法需要加上outerDocument.方法,或者Application.application.方法