Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
现代工具包extjs:空网格的上下文菜单_Extjs_Grid_Extjs6 Modern - Fatal编程技术网

现代工具包extjs:空网格的上下文菜单

现代工具包extjs:空网格的上下文菜单,extjs,grid,extjs6-modern,Extjs,Grid,Extjs6 Modern,在现代工具包extjs中,如何为空网格(没有行的网格)创建上下文菜单。我找到的最佳解决方案是在网格标题中添加上下文菜单。捕获headercontextmenu事件以执行此操作 问候-Gordon将contextmenu侦听器添加到网格元素: Ext.application({ name: 'Fiddle', launch: function () { const store = new Ext.data.Store({ fields: [

在现代工具包extjs中,如何为空网格(没有行的网格)创建上下文菜单。

我找到的最佳解决方案是在网格标题中添加上下文菜单。捕获headercontextmenu事件以执行此操作


问候-Gordon将contextmenu侦听器添加到网格元素:

Ext.application({
    name: 'Fiddle',

    launch: function () {
        const store = new Ext.data.Store({
            fields: ['name', 'email', 'phone'],
            data: []
        })

        const menu = new Ext.menu.Menu({
            items: [{
                text: 'Menu Item 01'
            }, {
                text: 'Menu Item 02'
            }]
        });

        Ext.Viewport.add({
            xclass: 'Ext.grid.Grid',
            store: store,
            title: "My Empty Grid",
            columns: [{
                text: 'Name',
                dataIndex: 'name',
                width: 200
            }, {
                text: 'Email',
                dataIndex: 'email',
                width: 250
            }, {
                text: 'Phone',
                dataIndex: 'phone',
                width: 120
            }],
            height: 500,
            listeners: {
                initialize: function (grid) {
                    grid.element.dom.addEventListener("contextmenu", function (event) {
                        menu.showAt(event.pageX, event.pageY);
                        event.stopImmediatePropagation();
                        if (event.preventDefault != undefined) {
                            event.preventDefault();
                        }
                        if (event.stopPropagation != undefined) {
                            event.stopPropagation();
                        }
                        return false;
                    });
                }
            }
        })
    }
})