我使用ExtJS 3.4
我有一个带节点的treepanel。我需要为每个节点创建上下文菜单。所以,我试图添加contextmenu,但得到TypeError:
未捕获的TypeError:无法读取属性' getXY'未定义的
出了什么问题?请帮帮我:)
Ext.onReady(function () {
var menustore = {
text: "Languages",
expanded: true,
children: [{
text: "C#",
leaf: true
}, {
text: "C++",
leaf: true
}, {
text: "Java",
leaf: true
}, {
text: "PHP",
leaf: true
}]
}
new Ext.tree.TreePanel({
renderTo: Ext.getBody(),
title: 'Languages',
root: menustore,
width: 170,
rootVisible: false,
id: 'tree-panel',
listeners: {
contextmenu: function (view, record, item, index, event) {
ContextMenu = new Ext.menu.Menu({
id: 'contxtmenu',
items: [{
text: 'Edit',
}]
});
ContextMenu.showAt(event.getXY());
event.stopEvent();
}
}
});
});
UPD:
我更改了参数,现在可以正常工作=)
listeners: {
contextmenu: function (node, event){
...
}
}