【发布时间】:2023-03-05 23:07:01
【问题描述】:
在我的 extjs 网格中,当我右键单击时,我会调用一个上下文菜单。当我单击其中一个项目时,我想在控制器中启动一个方法。这一切都成功了,问题是我想将调用它的父网格传递给控制器方法。有人可以告诉我怎么做吗?
这是我的上下文菜单
Ext.define('Example.ContextMenuTradematch', {
xtype: 'contextMenuTradematch',
extend: 'Ext.menu.Menu',
items: [
{
text: 'Match Trade',
iconCls: 'greenIcon',
listeners: {
click: {
fn: 'onMatchTrade',
params: {
param1: this
}
}
}
},
{
text: 'Delete Trade',
iconCls: 'deleteIcon',
listeners: {
click: 'onDeleteTrade'
}
}
]
});
那么这是我的控制器方法
onMatchTrade: function (event, target, options) {
debugger;
var me = this;
我如何访问发起事件的网格?
——这就是我将上下文菜单添加到网格的方式
title: 'Tradematch Results: UNMATCHED',
xtype: 'grid',
itemId: 'gridUnmatchedId',
ui: 'featuredpanel-framed',
cls: 'custom-grid',
margin: '0px 10px 0px 10px',
flex: 2,
width: '100%',
bind: {
store: '{myTM_ResultsStore}'
},
listeners: {
itemcontextmenu: 'showContextMenuTradematch'
},
这就是控制器添加它的方式...
getContextMenu: function (cMenu) {
if (!this.contextMenu) {
debugger;
this.contextMenu = this.getView().add({ xtype: cMenu });
}
return this.contextMenu;
},
showContextMenuTradematch: function (view, rec, node, index, e) {
e.stopEvent();
e.stopEvent();
debugger;
this.getContextMenu('contextMenuTradematch1').show().setPagePosition(e.getXY());
return false;
},
【问题讨论】:
-
网格是如何创建到控制器的?没有足够的上下文信息。
标签: extjs parameter-passing listener