3.0.0

onKeyDown : adding a new row lets the grid crash

Hello,

I forgot to set the subject in the other post.

Alex, this is realy driving me nuts for weeks.

I have a grid where a new row is added automaticaly when a user presses the "key down" key. This makes the grid a lot userfriendly, because then the user can keep on typing text.

This works fine. When you keep the "key down" key pressed, new rows are even added on the fly. There's only one bug.
- When you're cursor is in a cell from the last row and you press the "key down" key, a now row is added and the focus is moved to the new row.
- When you enter text in a cell from the last row and you press the "enter" key or another key and then the "key down" key, there is no problem. becasue the cell changes from edit mode to non-edit mode. The new row will be added and you can continue working.
- But when you enter text in a cell from the last row and press the "key down" key imediately, a new row will be added, but then the complete grid crashes. Probably becasue the cell was still in edit mode when you pressed the "key down" key and some validating events are fired on the cell.

obj.onKeyDown = function(){
if(obj.getCurrentRow() == (obj.getRowCount()-1)){
obj.addRow();
}
}

Has anybody any idea how to solve this?
Is there a way I can let the grid think I pressed the "enter" key for example?
e.g. : the "key down" key is pressed, then through javascript I let the grid think the "enter" key was pressed as well before the obj.addRow() command is executed.

Thanks!!
Kurt
April 27,

obj.onKeyDown = function(){
if(obj.getCurrentRow() == (obj.getRowCount()-1)){
this.setTimeout(function(){
obj.addRow();
});
}
}

April 28,
Yes, a timeout could be needed, but I think it is crashing because a missed setRowCount.
Are you using XML data model for this?

obj.onKeyDown = function(){
var x= obj.getRowCount();
if(obj.getCurrentRow() == (obj.getRowCount()-1)){
this.setTimeout(function(){
obj.addRow();
obj.setRowCount(x+1);
});
}
}

Carlos
April 28,
Hello guys,

Thank you very much for your answers. I already tried to add a timeout, but that didn't work.
But the solution from Carlos worked perfectly. The grid crashed because of the missing row count, perhaps in combination with the timeout.

Thanks again!! You realy saved me from a nervess brakedown.

Kurt
Kurt
April 28,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.