Flex DataGrid中控制某行不可编辑的例子
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.events.DataGridEvent; import mx.collections.ArrayCollection; [Bindable] private var list:ArrayCollection; private function init():void{ list = new ArrayCollection(); list.addItem({name:"litter",age:22,sex:'男',edit:false}); list.addItem({name:"SCL",age:22,sex:'女',edit:true}); list.addItem({name:"SKL",age:22,sex:'男',edit:false}); list.addItem({name:"newSkl",age:22,sex:'男',edit:true}); list.addItem({name:"changliangno1",age:22,sex:'女',edit:false}); list.addItem({name:"shichangliang",age:22,sex:'男',edit:true}); list.addItem({name:"weimingming",age:22,sex:'女',edit:false}); } private function doItemEditBegin(event:DataGridEvent):void{ if(Boolean(list.getItemAt(event.rowIndex).edit)){ _Grid.editedItemPosition = null; } } ]]> </mx:Script> <mx:DataGrid id="_Grid" x="199" y="141" width="436" editable="true" dataProvider="{list}" itemEditBegin="doItemEditBegin(event);" > <mx:columns> <mx:DataGridColumn headerText="Column 1" dataField="name"/> <mx:DataGridColumn headerText="Column 2" dataField="age"/> <mx:DataGridColumn headerText="Column 3" dataField="sex"/> <mx:DataGridColumn headerText="Column 3" dataField="edit" visible="false"/> </mx:columns> </mx:DataGrid></mx:Application>