extjs - ExtJS:如何在右键单击事件中获取所选网格记录的数据?
问题描述
我有一个grid
和一个上下文菜单功能。我在上下文菜单上添加了一个新项目,并尝试检索所选记录的数据以进行操作。
我怎样才能做到这一点?
在添加新项目期间覆盖方法;
getGridMenu: function () {
// This function calls base function for right-click events
var me = this;
var ret = [
{
text: 'Update Password',
handler: 'onUpdatePassword'
}
];
return me.callParent().concat(ret);
},
这是检索选定记录数据的问题。我需要确认选定的记录id
,然后我才能使用 CRUD 流程更新记录数据。
onUpdatePassword: function (button) {
var me = this;
Ext.MessageBox.confirm(translations.confirm, translations.confirmChangePassword, me.changePassword, me);
},
changePassword: function (button) {
var me = this;
if (button === "yes") {
//Successfully getting over here and here I need to declare selected row/record's data to manipulate it.
return new Ext.window.Window({
autoShow: true,
title: 'Create Password',
modal: true,
width: 250,
height: 160,
items: [
{
xtype: 'container',
height: 10
},
{
xtype: 'passwordfld',
width: 230,
inputType: 'password'
}
],
dockedItems: [
{
xtype: 'toolbar',
dock: 'bottom',
items: [
{
xtype: 'tbfill'
},
{
xtype: 'cancelbutton'
},
{
xtype: 'savebutton'
}
]
}
]
});
} else {
me.destroy();
}
},
解决方案
将项目的定义更改为:
{
text: 'Update Password',
listeners: {
click: this.onUpdatePassword,
scope: this
}
}
现在this
inonUpdatePassword
指的是网格
您可以通过以下方式访问选定的行this.getSelectionModel().getSelection()
推荐阅读
- java - 由于 FXML 文件中的控制器更改导致线程异常
- python - 删除 Tkinter 画布中的特定元素
- python - 如何将多个图像归因于神经网络中的同一观察?
- django - Django:过滤一个模型记录以显示其他模型的所有记录
- python - 从 IBM 无服务器功能下载文件时出错
- checkbox - 回发时 JQGrid 数据丢失
- python - 使用 matplotlib 限制 x 刻度的频率
- python - 如何将此 Curl 调用转换为 Python 3?
- xampp - Ubuntu 18.04 上的 sudo /opt/lampp/lampp 面板不起作用
- gitversion - 如何替换 GitVersion 配置中的默认分支?