开发者

How to end/stop item edit in Flex DataGrid

开发者 https://www.devze.com 2023-02-02 09:23 出处:网络
Normally, you update the data bound to a datagrid item like this: protected function onGridEditEnd(event:DataGridEvent):void

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

  1. End the edit (from another method or handler other than itemEditEnd handler)
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号