让Ext.Grid回车时焦点为下一个列

默认extjs中editorgrid编辑单元格的时候按回车是将焦点向下移动,按照一般的逻辑应该是向右移动。

其实只要将原先rowSelectionModel中onEditorKey方法override一下即可。

代码如下:

Ext.override(Ext.grid.RowSelectionModel, {

 onEditorKey : function(field, e) {
  var k = e.getKey(), newCell, g = this.grid, last = g.lastEdit, ed = g.activeEditor, shift = e.shiftKey, ae, last, r, c;

  if (k == e.TAB) {
   e.stopEvent();
   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.ENTER) {
   if (this.moveEditorOnEnter !== false) {
    if (shift) {
     newCell = g.walkCells(last.row, last.col - 1, -1,
       this.acceptsNav, this);
    } else {
     newCell = g.walkCells(last.row, last.col + 1, 1,
       this.acceptsNav, this);
    }
   }
  }
  if (newCell) {
   r = newCell[0];
   c = newCell[1];

   this.onEditorSelect(r, last.row);

   if (g.isEditor && g.editing) { // *** handle tabbing while
           // editorgrid is in edit mode
    ae = g.activeEditor;
    if (ae && ae.field.triggerBlur) {
     // *** if activeEditor is a TriggerField, explicitly call
     // its triggerBlur() method
     ae.field.triggerBlur();
    }
   }
   g.startEditing(r, c);
  }
 }
})

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦