// 右键菜单
showMenu : function(grid, index, e) {
 this.menu = new Ext.menu.Menu({
items : [{
id : 'add1',
text : '新建',
iconCls : 'add',
handler : function() {
this.create();
},
scope : this
}, {
id : 'modify1',
text : '编辑',
iconCls : 'modify',
handler : function() {
this.edit();
},
scope : this
}, {
id : 'del',
text : '删除',
iconCls : 'del',
handler : this.removeData,
scope : this
}, {
id : 'setRole',
text : '分配角色',
iconCls : 'setRole',
handler : this.setRole,
scope : this
}, {
id : 'setRight',
text : '分配权限',
iconCls : 'setRight',
handler : this.setRight,
scope : this
}]
});
e.preventDefault();
this.menu.showAt(e.getXY());
},initComponent : function() {
userInfoGrid.addListener("rowContextmenu", this.showMenu, this);
}

解决方案 »

  1.   

    不要在initComponent 中添加事件,直接在grid中添加即可
      

  2.   

    initComponent : function() {
    userInfoGrid = new Ext.grid.GridPanel({
    store : userInfoStore,
    cm : userInfColm,
    height : 300,
    stripeRows : true,
    pageSize : 10,
    tbar : [{
    text : '新加',
    id : 'add',
    pressed : false,
    iconCls : 'add',
    handler : function() {
    main.getActiveTab().create();
    },
    scope : this
    }],
    bbar : new Ext.PagingToolbar({
    pageSize : 10,
    store : userInfoStore,
    grid : userInfoGrid,
    displayInfo : true,
    displayMsg : '显示 {0} - {1}条记录  共有 {2} 条记录',
    emptyMsg : "没有记录"
    })
    });
    SMS.system.userInfo.superclass.initComponent.call(this);
    userInfoStore.load({
    params : {
    start : 0,
    limit : 10
    }
    });
    this.add(userInfoGrid);
    userInfoGrid.addListener("rowContextmenu", this.showMenu, this)

    }
      

  3.   

    initComponent 是初始化的时候执行的。
    直接写在grid的listeners:{rowContextmenu:function(){}}中
      

  4.   


    var userInfoGrid = new Ext.grid.GridPanel({
    store : userInfoStore,
    cm : userInfColm,
    height : 300,
    stripeRows : true,
    pageSize : 10,
    tbar : [{
    text : '新加',
    id : 'add',
    pressed : false,
    iconCls : 'add',
    handler : function() {
    main.getActiveTab().create();
    },
    scope : this
    }],
    bbar : new Ext.PagingToolbar({
    pageSize : 10,
    store : userInfoStore,
    grid : userInfoGrid,
    displayInfo : true,
    displayMsg : '显示 {0} - {1}条记录  共有 {2} 条记录',
    emptyMsg : "没有记录"
    })
    });
    SMS.system.userInfo.superclass.initComponent.call(this);
    userInfoStore.load({
    params : {
    start : 0,
    limit : 10
    }
    });
    this.add(userInfoGrid);
    userInfoGrid.addListener("rowContextmenu", this.showMenu, this);
    写在最外面就可以了,不要写在init函数中
      

  5.   

    我没跟你们改的时候
    他第一次的时候menu的值是有的
    第二次单击的时候有那个面板但是没有内容
      

  6.   

    var grid = new Ext.grid.GridPanel({
        id:"HisRptGrid",
    store:HisReportstore,
    sm:sm,
    cm:cm,
    loadMask:true,
                    listeners:{
                'contextmenu':function(e)
                {
                    e.stopEvent();
                },
                'rowcontextmenu':function(grid,rowIndex,e)
                {
                    e.stopEvent();
                    HisRptClick.showAt(e.getXY());
                }
    )};   var HisRptClick=new Ext.menu.Menu
            ({
                    items:
                    [{
                        text:'编辑记录',
                        iconCls:'editicon',
                        handler:EditHisRptFn
                    },{
                        text:'发布该记录',
                        iconCls:'deleteicon',
                        handler:PubHisRptInfo
                    }]
             });
      

  7.   

    我在
    要怎样才能得到我单击的列呢
    我这样写
    edit : function() {
    var record = userInfoGrid.getSelectionModel().getSelected();
    if (!record) {
    Ext.Msg.alert("提示", "请选择要编辑的行!");
    return;
    }
    this.showWin();
    this.fp.form.loadRecord(record);
    },
    我在数据中写了些按钮,只有当我单击那些按钮后,我在按菜单的选项才可以获的列
    能告诉我怎么读取列吗
    谢谢了啊