Extjs Grid 回车换行事件

来源:互联网 发布:网络分销合法吗 编辑:程序博客网 时间:2024/05/29 17:05
光标在行上横着走
Ext.override(Ext.grid.RowSelectionModel, {
    onEditorKey : function(field, e) {
     // alert('go');
     var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
     var shift = e.shiftKey;
     Ext.log('k:' + k);
     if (k == e.ENTER) {
      e.stopEvent();
      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);
       }
      }
     } 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);
   }
  }
 });
原创粉丝点击