How to end/stop item edit in Flex DataGrid
Normally, you update the data bound to a datagrid item like this:
protected function onGridEditEnd(event:DataGridEvent):void
{
if (grid.dataProvider != null && event != null)
{
var editor:Object = event.currentTarget.itemEditorInstance;
if (event.columnIndex == getColumnIndex(columnA) {
collection[event.rowIndex].name = TextInput(editor).text;
}
}
}
The itemEditEnd
event is dispatched right after the user finishes editing.
So, what if I want to
- End the edit (from another method or handler other than
itemEditEnd
handler) - Update the value of the bound data item at the same time.
"while" the item is being edited by the user.
For example; how do I trigger this from a keyDown
event handler?
Note: You could call onGridEditEnd(null)
which would end the edit but not update the data. onGridEditEnd(new DataGridEvent(DataGridEvent.ITEM_EDIT_END, ...))
would work but you also need to store and pass values like columnIndex, rowIndex, dataFiel开发者_开发技巧d, etc.. which does not seem to be the best and simplest way.
thanks...
try setting editable
property to false (then you can turn it back on).
Or you could try setting focus (FocusManager.focus = null
) elsewhere. This way it will be still editable, but the user will have to click it again.
精彩评论