当前位置: 代码迷 >> Web前端 >> EXT Enter切换焦点有关问题
  详细解决方案

EXT Enter切换焦点有关问题

热度:298   发布时间:2012-09-10 11:02:32.0
EXT Enter切换焦点问题
Enter键替代Tab键切换焦点(Ext)
一、el
var el =Ext.get('例如:formname');
var map = new Ext.KeyMap(el, {
key: Ext.EventObject.ENTER,
fn: function(){
event.keyCode=9;
}
});

二、EditGrid,需修改源码
onEditorKey:function (F, E) {
var C = E.getKey(), G, D = this.grid, B = D.activeEditor;
var A = E.shiftKey;
if (C == E.TAB) {
  E.stopEvent();
  B.completeEdit();
  if (A) {
   G = D.walkCells(B.row, B.col - 1, -1, this.acceptsNav, this);
  } else {
   G = D.walkCells(B.row, B.col + 1, 1, this.acceptsNav, this);
  }
} else {
  if (C == E.ENTER) {
   E.stopEvent();
   B.completeEdit();
   if (this.moveEditorOnEnter !== false) {
    if (A) {
     //G = D.walkCells(B.row - 1, B.col, -1, this.acceptsNav,this)
     G = D.walkCells(B.row, B.col - 1, -1, this.acceptsNav, this);
    } else {
     // G = D.walkCells(B.row + 1, B.col, 1, this.acceptsNav,this)
     G = D.walkCells(B.row, B.col + 1, 1, this.acceptsNav, this);
    }
   }
  } else {
   if (C == E.ESC) {
    B.cancelEdit();
   }
  }
}
if (G) {
  D.startEditing(G[0], G[1]);
}
}
  相关解决方案