所有的List 组件都可以通过简单地设置list 的editable 属性为true 使之可编辑。这就意
味着每一个渲染都将变成一个由TextInput 模块控制和用户选择的itemRenderer 填充值的
编辑器,List 类同样定义了一些当用户开始和结束修改正在编辑的值的时候用来通知应用程
序的事件:
itemEditBegin:当editedItemPosition 属性已设置且项目可编辑后调度。当事件被触发,List组件使用createItemEditor 方法并且从编辑器拷贝data 属性来创建一个itemEditor 对象
itemEditBeginning:当用户准备好编辑项目(例如,在项目上释放鼠标按键)后调度,聚
焦到列表或试图编辑列表
itemEditEnd:当项目编辑会话因任何原因而结束时调度。List 组件为这个拷贝自条目编辑
器至list 组件的数据提供者的数据提供了一个默认的事件处理方式,默认情况下,List 组件
使用editorDataField 属性来决定itemEditor 的属性包括新数据和使用新数据更新条目数
据。
listImpl.editedItemPosition = {columnIndex:0,
rowIndex:3};
选择第一列第四个
味着每一个渲染都将变成一个由TextInput 模块控制和用户选择的itemRenderer 填充值的
编辑器,List 类同样定义了一些当用户开始和结束修改正在编辑的值的时候用来通知应用程
序的事件:
itemEditBegin:当editedItemPosition 属性已设置且项目可编辑后调度。当事件被触发,List组件使用createItemEditor 方法并且从编辑器拷贝data 属性来创建一个itemEditor 对象
itemEditBeginning:当用户准备好编辑项目(例如,在项目上释放鼠标按键)后调度,聚
焦到列表或试图编辑列表
itemEditEnd:当项目编辑会话因任何原因而结束时调度。List 组件为这个拷贝自条目编辑
器至list 组件的数据提供者的数据提供了一个默认的事件处理方式,默认情况下,List 组件
使用editorDataField 属性来决定itemEditor 的属性包括新数据和使用新数据更新条目数
据。
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="absolute">
- <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400"
- height="300">
- <mx:Script>
- <![CDATA[
- [Bindable]
- private var dp:Array = [{name:"John Smith", foo:"bar"},
- {name:"Ellen Smith", foo:"baz"},
- {name:"James Smith", foo:"eggs"},
- {name:"Jane Smith", foo:"spam"}]
- private function editEnd(event:Event):void {
- trace(listImpl.selectedItem.foo+''+listImpl.selectedItem.name);
- }
- private function setEditor():void {
- listImpl.editedItemPosition = {columnIndex:0,
- rowIndex:3};
- }
- ]]>
- </mx:Script>
- <mx:Button click="setEditor()"/>
- <mx:List y="30" width="200" selectedIndex="6" id="listImpl"
- selectionColor="#CCCCFF" labelField="name"
- dataProvider="{dp}"
- editable="true"
- itemEditBegin="trace(listImpl.editedItemPosition)"
- itemEditEnd="editEnd(event)" editorXOffset="5"
- editorYOffset="2"/>
- </mx:Canvas>
- </mx:Application>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400"
height="300">
<mx:Script>
<![CDATA[
[Bindable]
private var dp:Array = [{name:"John Smith", foo:"bar"},
{name:"Ellen Smith", foo:"baz"},
{name:"James Smith", foo:"eggs"},
{name:"Jane Smith", foo:"spam"}]
private function editEnd(event:Event):void {
trace(listImpl.selectedItem.foo+''+listImpl.selectedItem.name);
}
private function setEditor():void {
listImpl.editedItemPosition = {columnIndex:0,
rowIndex:3};
}
]]>
</mx:Script>
<mx:Button click="setEditor()"/>
<mx:List y="30" width="200" selectedIndex="6" id="listImpl"
selectionColor="#CCCCFF" labelField="name"
dataProvider="{dp}"
editable="true"
itemEditBegin="trace(listImpl.editedItemPosition)"
itemEditEnd="editEnd(event)" editorXOffset="5"
editorYOffset="2"/>
</mx:Canvas>
</mx:Application>
listImpl.editedItemPosition = {columnIndex:0,
rowIndex:3};
选择第一列第四个