在用 extjs editorgridpanel 进行输入编辑的时候, 默认情况下只支持使用 tab 键可以实现焦点切换, 如果需要支持 enter 键实现焦点跳转切换, 则只需加上写列代码
Ext.override(Ext.grid.RowSelectionModel, {
onEditorKey : function(field, e) {
var k = e.getKey(), newCell, g = this.grid,l = g.lastEdit, ed = g.activeEditor;
var shift = e.shiftKey;
if(ed){
}else{
ed=l;
}
if (k == e.ENTER || k == e.TAB) {
e.stopEvent();
if(ed){
ed.completeEdit();
}
if (shift) {
newCell = g.walkCells(ed.row, ed.col - 1, -1, this.acceptsNav, this);
} else {
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]);
}
}
});