Making your datagrid commit the current cell and maintain focus on that row
The default behavior of editing a cell in a Flex DataGrid is such that if you hit the enter key is moves to the next cell down, and tab moves to the next cell to the right.
If you want it so that when you hit tab or enter, that it just commits that current cell and stays on that row in uneditted mode you'll want to combine callLater() and the itemEditEnd event.
<mx:Script>
private function maintainFocus():void
{
dg.editedItemPosition = null;
}
</mx:Script>
<mx:DataGrid editable="true" sortableColumns="false" id="dg" itemEditEnd="callLater(maintainFocus)" id="dg">
...
...
</mx:DatgaGrid>
本文介绍如何在 Flex DataGrid 中编辑单元格时,使用 enter 或 tab 键提交当前单元格并保持在同一行的焦点,避免默认情况下焦点跳转到下一个单元格。通过结合使用 callLater() 函数与 itemEditEnd 事件,可以实现这一功能。


被折叠的 条评论
为什么被折叠?



