extjs - extjs6 - 网格上下文菜单,通过行选择
问题描述
在我的 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.
推荐阅读
- airflow - Apache Airflow 任务超时
- python - 从 PubMed find_element_by_css_selector VS visibility_of_all_elements_located 中抓取文本
- javascript - 我可以将对象数组存储在具有相同属性的本地存储中吗?即使我在 JavaScript 中刷新页面,它也会保留下来?
- android - 错误:无法在项目中找到模块“XXXXX”
- mongodb - 将所有对象合并到一个组中并保留所有先前的字段
- selenium-chromedriver - 如何在 chromedriver 中手动验证假视频流
- java - 无法从 Java Spring Boot 项目中的 application.yml 文件中读取用户定义类的列表
- r - 如何计算每列(按组)中满足 R 中特定条件的行数
- javascript - 如何在按下按钮时更新 ngx-timeago 语言?
- javascript - 使用递归函数将数组中的每个单词大写