今天继续介绍一下DataGrid的编辑功能,
编辑状态操作非常简单,只需要设置editable=""true"",
但需要注意的事,要先设置DataGrid开启全局的编辑功能,
然后再针对DataGridColumn(列)把不需要编辑的列用editable=""false""取消编辑功能。
<?xml version=""1.0""?>
<mx:Application xmlns:mx=""http://www.adobe.com/2006/mxml""
layout=""absolute"" width=""450"" fontFamily=""宋体"" fontSize=""12"" height=""230"">
<mx:Script>
<![CDATA[
import mx.controls.*;
import mx.events.ListEvent;
import mx.controls.dataGridClasses.*;
private var DataGrid1:DataGrid;
[Bindable]//原始数据
public var dataArr:Array = [{id:1,name:""苹果"",count:100},
{id:2,name:""西瓜"",count:200},
{id:3,name:""水蜜桃"",count:50}]
]]>
</mx:Script>
<mx:DataGrid editable=""true"" id=""DataGrid2""
dataProvider=""{dataArr}"" width=""430"" y=""10"" x=""10"" height=""208"">
<mx:columns>
<mx:DataGridColumn headerText=""序号"" dataField=""id"" editable=""false""/>
<mx:DataGridColumn headerText=""名称"" dataField=""name""/>
<mx:DataGridColumn headerText=""数量"" dataField=""count""/>
</mx:columns>
</mx:DataGrid>
</mx:Application>