Macromedia Flex Macromedia Flex
Preventing enter or tab from moving onto the next cell
  Home

Jun 28, 2007 - Preventing enter or tab from moving onto the next cell
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>

Thanks to Peter Deseloper for help on this.

File Details
Created On Jun, 28, 2007 by Tariq Ahmed
Last Modified On Jun, 28, 2007 by Tariq Ahmed
Group: Tips and Articles
Flex Versions: 2.0
Category: Controls:Lists (eg DataGrid/Tile/Tree)
Type: Tip
Difficulty: Intermediate
Keywords: events