我会将处理程序添加到用于编辑值的组件而不是 ArrayCollection。例子:
<mx:DataGridColumn dataField="name" headerText="Name" itemEditor="{nameEditor}" editorDataField="selectedItem" />
然后这用于编辑值:
<mx:Component id="nameEditor">
<mx:ComboBox dataProvider="{outerDocument.names}" change="outerDocument.setNameField(event)" close="outerDocument.setNameField(event)" />
</mx:Component>
这是更改(和关闭)事件的处理程序:
public function setDestinationField(event:*):void {
var destination:String = (event.target as ComboBox).selectedLabel;
if (destination === '') {
delete _gridData[_currentlyEditedRowIndex].destination;
} else {
_gridData[_currentlyEditedRowIndex].destination = destination;
}
}
_currentlyEditedRowIndex
通过将其添加到网格来设置:
itemEditBegin="beginEdit(event);"