PDA

View Full Version : [SOLVED] grid : afteredit : edit next cell in row...



sj137
6 Jun 2007, 6:21 AM
Hi,

My problem is that the eventlistener function i call, does what it's supposed to and then does something else...

when a new row is added to the top of the Editor Grid, I add a listener like this to the code:

grid.on('afteredit', nxCell);

where:

function nxCell(e){
grid.startEditing(0, 2);
}

the current cell is always row 0, column 1, so the editor moves to the correct cell when 'afteredit' fires (0,2)

...but then with pause it immediately goes to the cell beneath the initial editing cell (ie row 1, column 1)

what am i doing wrong or how can i get the behaviour I'm after?

Many thanks in advance

SJ

PS I've been search the doc and api, trying out and testing things too, but to no avail, i the think the best option would be to listen for key events instead...? on keypress or on keydown...

tryanDLS
6 Jun 2007, 6:35 AM
This may be a timing issue b/c your starting a new edit before the previous edit (onEditComplete) has a chance to finish and set focus back to the cell. You could try adding a defer to your startEditing call to delay it slightly - not tested, just a thought.

sj137
6 Jun 2007, 6:56 AM
Thanks for the quick reply, I tried adding a defer like this:

grid.startEditing(0, 2).defer(1000);

it works in firefox but firebug displays the error:

grid.startEditing(0, 2).defer(1000) has no properties, and in internet explorer theres a script error pop up message.

this looks promising however,
...have i used the defer correctly...? i'm not sure what the other params it takes...

tryanDLS
6 Jun 2007, 8:25 AM
I think you want


grid.startEditing.defer(1000, grid, [0,2])


Check out the doc for Function.defer for further details.

sj137
7 Jun 2007, 2:54 AM
that worked a treat and i understand the params now tooo:D

the focus can be seen flicking down before going across, which isn't ideal... but will do for now.

Many thanks :)

sj137
7 Jun 2007, 4:56 AM
...unfortunately it doesn't look as clean as it could due to the editor-box-focus moving around alot before finding the target cell, even if i reduce the time delay to around 100 milli-seconds :(

therefore is it possible to override the default downward-movement of the focus when a user hits 'enter' after editing... :-?

so instead of the 'enter' key making the focus move downward, i would like the action that the 'tab' key causes - ie the focus moves across... but i'm confused as to where to start in order to make this happen... :s

...any pointers in the right direction would be much appreciated ;)

I've looked at adding on keypress and on keydown listeners but they only appear to fire when the grid is not in 'editing' mode...

Many thanks in advance:)

sj137
24 Jun 2007, 11:44 AM
check out my post here:

http://extjs.com/forum/showthread.php?t=4888

:)