That had some interesting results. In the KeyDown event handler I set editedItemPosition as per your suggestion and I commented out all of the code in my endEdit handler (but did not removed the handler from the datagrid). To my delight, I could arrow down the column with no issues.
Then I uncommented my endEdit code and the new cell would never gain focus (or gained it and lost it immediately, not sure which). A second test was to re-comment all the endEdit code except for the event.preventDefault at the beginning and DataGrid(event.currentTarget).destroyItemEditor at the end. The same results. That is, the new cell would not gain focus. This brought the realization that I was using the preventDefault method incorrectly. It is this call that disallows focus to move to the new cell. Once I commented it out and restored all the other code of the endEdit handler, it worked like a charm. Thanks for taking the time to suggest another way to look at things. I appreciate it a lot. --- In [email protected], "Alex Harui" <[EMAIL PROTECTED]> wrote: > > Maybe. If you force too many updates on the DG, it might close out the > edit session. It might be worth trying it w/o your endEdit logic to see > if that is causing the focus issue. > > If on some keystroke you simply set editedItemPosition, the code says > that it will dispatch ITEM_EDIT_END before trying to set the editor to > the new place. > > -Alex > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of Mike_Robinson_98 > Sent: Tuesday, May 08, 2007 9:43 AM > To: [email protected] > Subject: [flexcoders] Re: Keyboarding up/down editable columns in > Datagrid > > > > I need to handle the endEdit event to do some data massaging on the > input as well as update other values based on that input value. > Besides, it seems to me that the end result would be the same whether I > handled endEdit or the DG handled endEdit, that is losing of focus in > the new cell. Yes? > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> > , "Alex Harui" aharui@ wrote: > > > > What are you using the endEdit for? You should just let the DG call > it > > when you change editedItemPosition. > > > > ________________________________ > > > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> > [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> > ] > On > > Behalf Of Mike_Robinson_98 > > Sent: Monday, May 07, 2007 9:02 PM > > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > > Subject: [flexcoders] Re: Keyboarding up/down editable columns in > > Datagrid > > > > > > > > --- In [email protected] > <mailto:flexcoders%40yahoogroups.com> > <mailto:flexcoders%40yahoogroups.com> > > , "Mike_Robinson_98" > > mike_robinson_98@ wrote: > > > > > > --- In [email protected] > <mailto:flexcoders%40yahoogroups.com> > > <mailto:flexcoders%40yahoogroups.com> , "Manish Jethani" > > > <manish.jethani@> wrote: > > > > > > > > On 5/8/07, Mike_Robinson_98 <mike_robinson_98@> wrote: > > > > > Has anyone come up with a good way to let a user move up/down in > > an > > > > > editable column of a datagrid using the keyboard? These columns > > use a > > > > > TextInput as the itemEditor. > > > > > > > > > > Right now I use a handler for the keyFocusChangeEvent on the > > datagrid > > > > > to handle TAB and Shift-TAB keys to move horizontally through > the > > > > > rows. However, moving up/down in the columns is more difficult > > because > > > > > the editor's TextInput captures the Return key and the > > > > > TextFieldAutomationHelper class captures all the other > interesting > > > > > keystrokes (navigation keys like UP and DOWN arrows) and it > > seems the > > > > > DataGrid is only interested in the TAB key when it handles > > focusChange > > > > > events. > > > > > > > > This simple test worked for me: > > > > > > > > <?xml version="1.0"?> > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml > <http://www.adobe.com/2006/mxml> > > <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > " > > > > xmlns="*"> > > > > <mx:DataGrid id="dg" editable="true" keyDown="handleKeyDown()"> > > > > <mx:dataProvider> > > > > <mx:Object name="foo" value="1" /> > > > > <mx:Object name="bar" value="2" /> > > > > </mx:dataProvider> > > > > </mx:DataGrid> > > > > <mx:Script> > > > > private function handleKeyDown():void > > > > { > > > > var v:Object = dg.editedItemPosition; > > > > v.rowIndex++; > > > > dg.editedItemPosition = v; > > > > } > > > > </mx:Script> > > > > </mx:Application> > > > > > > > > Use the down arrow key to move from foo to bar. > > > > > > > Thanks a lot for the reply. That is a nice, simple solution. > > > > > > I have one more slight problem along this line maybe you could shed > > > some light on. In my app, I use the endEdit function for the > datagrid. > > > Unfortunately, although I move the focus to the column in the new > row, > > > the endEdit code gets call after this focus occurs and consequently > > > focus is lost. I have tried 'callLater' for the focus method but > have > > > the same result. Even, setup a timer to delay the focus for 200 ms. > > > Still endedit come along and focus is lost. Have you or any other > > > reader run into this issue? > > > > > Another note - actually, the setting of the focus is what is causing > > the endedit event for the previous cell. Seems like a catch-22. > > Setting the focus caused the endevent for the previous cell which then > > causes the current cell to lose focus. Again, I am probably making > > things too complex. > > >

