ExtJS:如何在右键单击事件中获取所选网格记录的数据?

标签 extjs grid record right-click

我有一个网格和一个上下文菜单功能。我在上下文菜单中添加了一个新项目,并尝试检索所选记录的数据进行操作。

我怎样才能实现这个目标?

以及添加新项目期间的重写方法;

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/

相关文章:

php - Sencha Touch 文件上传问题

javascript - 无法在 extJS 中显示图像

java - 使用坐标在网格中查找图 block

javascript - 带有缩略图的 WordPress 扩展网格

javascript - ExtJs 4.2,来自存储加载事件的网格 relayEvents 导致未捕获的类型错误 : undefined is not a function

record - 在 Navicat 中复制记录的简单方法

javascript - Ext js 6.2, 固定西面板不塌?

进行操作时的 ExtJS 掩码面板

sql - 如果没有找到记录则返回一个值

php - 每个搜索结果都需要谷歌分析