日期:2014-05-16 浏览次数:20459 次
单击DataGrid单元格编辑出现ComboBox,选择相应的值,要使数据写入数据库就要调用DataGrid的itemEditEnd事件,itemEditEnd事件是在离开编辑单元格后触发的.
itemEditEnd事件调用的方法
private function updatePro(event:DataGridEvent):void{ var dataField:String = event.dataField;//获取绑定字段的名称 var proId:String = mydate.selectedItem.proId;//获取id if(dataField=="completePreStr"){ var newData:String = ""; try{ newData = ComboBox(event.currentTarget.itemEditorInstance).selectedLabel//获取编辑后的新值 }catch(errObject:Error){ } //判断为null的情况,否则很容易出现TypeError: Error #1009: 无法访问空对象引用的属性或方法 if(newData!=null){ myProService.updateCompletePreStr(proId,newData);//调用更新方法 } } }
?全部源码:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="white" creationComplete="init2();init();" height="1332" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FCFCFC, #040303]" xmlns:local="*" xmlns:ns1="com.esria.samples.dashboard.view.*"> <mx:Script> <![CDATA[ import mx.controls.List; import mx.collections.ArrayCollection; import mx.events.CuePointEvent; import mx.events.VideoEvent; import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.events.DataGridEvent; [Bindable] private var FLV_URL:String = "zhajm_126296095230hd.flv"; [Bindable] private var userInfoList:ArrayCollection; [Bindable] private var userInfo:Object; [Bindable] public var cards:ArrayCollection; /** * Initialize the ArrayCollection object. */ private function init():void { department.getDepartment(); } private function init2():void { myservice.getProInfo("",""); } public function resultHandler(result:ResultEvent):void{ userInfoList = result.result as ArrayCollection; userInfo = userInfoList.getItemAt(0); //Alert.show(userInfo.userName); } private function changeHandler(event:Event):void { myservice.getProInfo(departmentId.text,pageNum.text); } private function closeHandler(result:ResultEvent):void { cards = result.result as ArrayCollection; } private function formatDate(item:Object,column:DataGridColumn):String{ if (item[column.dataField] == null) { return "-"; } return FD.format(item[column.dataField]); } private function formatPre(item:Object,column:DataGridColumn):String{ if (item[column.dataField] == null) { return "-"; } if (item[column.dataField] == 1) { return "模型"; } if (item[column.dataField] == 2) { return "预演"; } if (item[column.dataField] == 3) { return "小样"; } if (item[column.dataField] == 4) { return "渲染"; } if (item[column.dataField] == 5) { return "后期"; } return item[column.dataField]; } private function updatePro(event:DataGridEvent):void{ var dataField:String = event.dataField;//获取绑定字段的名称 var proId:String = mydate.selectedItem.proId;//获取id