您好我正在尝试在右键单击数据视图项时显示上下文菜单。我处理了 itemcontextmenu事件,在该事件中我实例化了 Ext.menu.Menu 并调用了它的showAt方法,但它给了我错误,因为TypeError: me.el.translatePoints is not a function in Component.js
我观察到el是undefined,应该给它分配什么值才能使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());
}
}
}