PDA

View Full Version : Disabling TAB keys or altering its behavior on EditorGridq



j-joey
1 Aug 2010, 8:15 AM
Hi there,

In my grid, there is only one column that can be edited, so TAB keys forces editors to lost focus when editing.

I was looking a way to prevent TAB keys then i noticed the idea that you can override the onEditorKey event of selection model of a rendered grid.

Thanks to createInterceptor method, i came up with this solution:

in this solution I just prevent TAB keys to fire onEditorKey event


grid.selModel.onEditorKey = grid.selModel.onEditorKey.createInterceptor( function( field, e ) {
if ( e.getKey() == e.TAB ) {
e.stopEvent();
return false;
}
}


here I change TAB behavior to ENTER behavior by just altering the Event object.


grid.selModel.onEditorKey = grid.selModel.onEditorKey.createInterceptor( function( field, e ) {
if ( e.getKey() == e.TAB ) {
e.keyCode = e.ENTER;
e.button = e.ENTER - 1;
}
}


I hope this solutions will help you guys...