0

您好我正在尝试在右键单击数据视图项时显示上下文菜单。我处理了 itemcontextmenu事件,在该事件中我实例化了 Ext.menu.Menu 并调用了它的showAt方法,但它给了我错误,因为TypeError: me.el.translatePoints is not a function in Component.js

我观察到elundefined,应该给它分配什么值才能使translatePoints函数起作用?或者可以有其他解决方法?

请在下面找到我的代码:

    {
        xtype: 'dataview',
        store: 'SearchedGraphics',
        tpl: [
            '<tpl for=".">',
                '<div class="thumb-wrap" id="{name:stripTags}">',
                '<div class="thumb"><table><tr><td><img class="img" src="{url}" title="{name:htmlEncode}"></td></tr></table></div>',
                '<span class="x-editable">{shortName:htmlEncode}</span>',
                '</div>',
            '</tpl>',
            '<div class="x-clear"></div>'
        ],
        multiSelect: true,
        height: 310,
        trackOver: true,
        overItemCls: 'x-item-over',
        itemSelector: 'div.thumb-wrap',
        emptyText: ORT.Utility.GridEmptyText,

        prepareData: function(data) {
            Ext.apply(data, {
                shortName: Ext.util.Format.ellipsis(data.name, 15),
                sizeString: Ext.util.Format.fileSize(data.size),
                dateString: Ext.util.Format.date(data.lastmod, "m/d/Y g:i a")
            });
            return data;
        },
        listeners: {
            selectionchange: function(dv, nodes ){
                if(false) {
                    var l = nodes.length,
                    s = l !== 1 ? 's' : '';
                    this.up('panel').setTitle('Simple DataView (' + l + ' item' + s + ' selected)');
                }
            },
            itemcontextmenu: function(dataview, record, item, index, event, eOpts){

                var menu = Ext.create('Ext.menu.Menu', {
                    width: 100,
                    el:'p',
                    margin: '0 0 10 0',
                    floating: false,  
                    items: [{
                        text: 'regular item 1'
                    },{
                        text: 'regular item 2'
                    },{
                        text: 'regular item 3'
                    }]
                }).showAt(event.getXY());

            }
        }
    }
4

1 回答 1

1

1)不确定为什么将浮动设置为假。这是一个菜单,所以它应该是浮动的。

2)您根本不应该设置 el 配置。

于 2012-11-07T09:55:56.157 回答