flex 的mx:DataGrid 的itemDoubleClick 和 DoubleClick
最近项目中遇到的问题 ,之前代码如下:
<mx:DataGrid id="myDataGrid" width="100%" height="100%" fontSize="12" dataProvider="{ListData}" doubleClickEnabled="true" doubleClick="itemListClickHander(event)">
调用代码如下:
private function itemListClickHander(e:MouseEvent):void{var selectItem:Object=e.currentTarget.selectedItem;//mainFrame.selectedChild=editUser;//NOTES: bug,双击空白处弹出窗口的bug BY:2012-10-10//var selectItem:Object=myDataGrid.selectedItemif(myDataGrid.selectedItem!=null && selectItem !=null){ var obj:*=mx.managers.PopUpManager.createPopUp(this, editUser, true); obj.RecordID=selectItem.@RecordID; obj.DoorID=MyEvents.CurrentDoorNode.@RecordID; obj.CallBackFun=this.CallBackFun; mx.managers.PopUpManager.centerPopUp(obj); obj.init();}}
上面代码的问题是:如果选中了列表中的记录,在双击列表空白处仍热能弹出编辑窗口,不合理喔;
解决方法:doubleClick 改为 itemDoubleClick ,只对有数据的记录行有效。
<mx:DataGrid id="myDataGrid" width="100%" height="100%" fontSize="12" dataProvider="{ListData}" doubleClickEnabled="true" itemDoubleClick="itemListClickHander()">
调用代码如下:
private function itemListClickHander():void{//var selectItem:Object=e.currentTarget.selectedItem;//mainFrame.selectedChild=editUser;//NOTES: bug,双击空白处弹出窗口的bug BY:2012-10-10var selectItem:Object=myDataGrid.selectedItemif(myDataGrid.selectedItem!=null){ var obj:*=mx.managers.PopUpManager.createPopUp(this, editUser, true); obj.RecordID=selectItem.@RecordID; obj.DoorID=MyEvents.CurrentDoorNode.@RecordID; obj.CallBackFun=this.CallBackFun; mx.managers.PopUpManager.centerPopUp(obj); obj.init();}}