http://blog.csdn.net /traceofsun/archive/2010/08/13/5808648.aspx, 但是在extjs3.1以后 ,此类方法失效提示ed为null,经过查证,稍加修改(注意红色加粗部分代码),现在可以正常使用,与大家共饷
/*
作者:eycbest
时间:20100907
网址:http://www.cnblogs.com/eycbest
*/
Ext.override(Ext.grid.RowSelectionModel, {
onEditorKey : function (field, e) {
// alert('go');
// alert( this.grid.activeEditor);
var k = e.getKey(), newCell, g = this .grid, l = g.lastEdit , ed = g.activeEditor;
var shift = e.shiftKey;
// Ext.log('k:' + k);
if (ed){
} else {
ed = l;
}
if (k == e.ENTER) {
e.stopEvent();
if (ed){
// ed.completeEdit();
}
if (shift) {
newCell = g.walkCells(ed.row, ed.col - 1 , - 1 ,
this .acceptsNav, this );
} else {
// alert('go');
newCell = g.walkCells(ed.row, ed.col + 1 , 1 ,
this .acceptsNav, this );
}
} else if (k == e.TAB) {
e.stopEvent();
ed.completeEdit();
if ( this .moveEditorOnEnter !== false ) {
if (shift) {
newCell = g.walkCells(ed.row - 1 , ed.col, - 1 ,
this .acceptsNav, this );
} else {
// alert('go');
// newCell = g.walkCells(ed.row + 1, ed.col, 1,
// this.acceptsNav, this);
newCell = g.walkCells(ed.row, ed.col + 1 , 1 ,
this .acceptsNav, this );
}
}
} else if (k == e.ESC) {
ed.cancelEdit();
}
if (newCell) {
g.startEditing(newCell[ 0 ], newCell[ 1 ]);
}
}
});
var sm2 = new Ext.grid.RowSelectionModel({
moveEditorOnEnter : true ,
singleSelect : true ,
listeners : {
rowselect : function (sm, row, rec) {
centerForm.getForm().loadRecord(rec);
}
}
});