extjs右键菜单
extjs中的gridpanel、TreePanel等控件都可以有右键菜单,如下设置。
代码
listeners: {
render: function() {
// After the component has been rendered, disable the default browser context menu
Ext.getBody().on("contextmenu", Ext.emptyFn, null, {preventDefault: true});
},
contextmenu: function(e) { //在gridpanel中可以使用rowcontextmenu事件
// Init your context menu
this.cmenu = new Ext.menu.Menu({
items: [ {
text: 'Close Other'
}, {
text: 'Close All'
}]
})
e.stopEvent();
this.cmenu.showAt(e.getPoint());
}
}
render: function() {
// After the component has been rendered, disable the default browser context menu
Ext.getBody().on("contextmenu", Ext.emptyFn, null, {preventDefault: true});
},
contextmenu: function(e) { //在gridpanel中可以使用rowcontextmenu事件
// Init your context menu
this.cmenu = new Ext.menu.Menu({
items: [ {
text: 'Close Other'
}, {
text: 'Close All'
}]
})
e.stopEvent();
this.cmenu.showAt(e.getPoint());
}
}