iteye_2005 2010-06-06 20:23
浏览 236
已采纳

extjs3.1版本grid不能用回车导航,老版本可以,请那位好心人帮忙解决

下面的代码在ext3.0中可以,可是到了3.1,总是报ed为Null的错误。但是tab键却可以。

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) {
                    //alert("回车后,单元格焦点位置事件1");
                    //alert(grid.activeEditor.field.isValid(true));
                    e.stopEvent();   
                    ed.completeEdit();   
                    if (shift) {   
                        newCell = g.walkCells(ed.row, ed.col - 1, -1,   
                                this.acceptsNav, this);   
                    } else {   
                        // alert('go');  
                        //alert("回车后,单元格焦点位置事件2");
                        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]);  //newCell是一个数组,包含了rowIndex,colIndex 
                }   
            }   
        });
  • 写回答

1条回答 默认 最新

  • chem_zqm 2010-06-06 20:38
    关注

    方法重写啊,这个你得去看RowSelectionModel的源码了,我估计是你这里的enter事件之前editor就被销毁了。下面是3.2的那一段代码:
    [code="js"]
    else if(k == e.ENTER){
    if(this.moveEditorOnEnter !== false){
    if(shift){
    newCell = g.walkCells(last.row - 1, last.col, -1, this.acceptsNav, this);
    }else{
    newCell = g.walkCells(last.row + 1, last.col, 1, this.acceptsNav, this);
    }
    }
    }
    [/code]
    里面根本就没有使用对Editor的引用

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波