我有一个网格
和一个上下文菜单功能。我在上下文菜单中添加了一个新项目,并尝试检索所选记录的数据进行操作。
我怎样才能实现这个目标?
以及添加新项目期间的重写方法;
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
}
}
现在onUpdatePassword
中的this
指的是网格
并且您可以通过 this.getSelectionModel().getSelection() 访问选定的行
关于ExtJS:如何在右键单击事件中获取所选网格记录的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50569590/