在我的extjs6项目中,我有一个网格,我想添加右键单击网格、从菜单栏中选择项目并启动弹出窗口的功能,但将行选择传递到单击方法。
到目前为止,我的右键菜单栏可以工作,但当点击菜单项时,我想从网格中穿过选定的行。有人能帮我把网格行选择传递给控制器方法吗?
我的观点
Ext.define('Example.ContextMenu', {
xtype: 'contextMenuMarketDrilldownAccount',
extend: 'Ext.menu.Menu',
items: [{
text: 'Market Drilldown by Account',
listeners: {
click: 'onDownloadTopdayRecapContextButton2'
}
}]
});
//removing a lot of code to make it readable here
xtype: 'grid',
title: 'Details',
itemId: 'detailsGridID',
bind: {
store: '{myDetailsStore}'
},
flex: 3,
margin: '5px 0px 0px 0px',
ui: 'featuredpanel-framed',
cls: 'custom-grid',
height: '100%',
collapsible: true,
collapseDirection: 'left',
listeners: {
itemcontextmenu: 'showContextMenu2'
},
控制器
showContextMenu2: function (view, rec, node, index, e) {
e.stopEvent();
debugger;
//var selectedMarket = rec.get('BBSymbol');
this.getContextMenu2().show().setPagePosition(e.getXY());
return false;
},
getContextMenu2: function () {
if (!this.contextMenu) {
this.contextMenu = this.getView().add({ xtype: 'contextMenuMarketDrilldownAccount' });
}
return this.contextMenu;
},
若要解决此问题,请将块this.getContextMenu2((更改为this.getContextMenu2(rec(
showContextMenu2: function (view, rec, node, index, e) {
e.stopEvent();
debugger;
//var selectedMarket = rec.get('BBSymbol');
this.getContextMenu2(rec).show().setPagePosition(e.getXY());
return false;
},
getContextMenu2: function (rec) {
if (!this.contextMenu) {
this.contextMenu = this.getView().add({
xtype: 'contextMenuMarketDrilldownAccount',
currentRecord: rec
});
}
return this.contextMenu;
}
//Then you catch a currentRecord on a contextMenuMarketDrilldownAccount component.