您的位置:首页 > 其它

EXT4 树 右键菜单 显示问题

2012-11-07 18:20 489 查看
转自:http://pcat.s23-213.myverydz.com/forum.php?mod=viewthread&tid=1006

Ext.define("AM.view.treeView",{

extend:"Ext.tree.Panel",

title: "组织机构列表",

frame: true,

region: "west", //呈现在西边,即是左边

width: 210,

margin: "1 0 0 3",

collapsible: true, //是否可以收缩

id:"treeID",

border : true,

rootVisible: true,

padding:"0 0 0 0",

dockedItems:[{

xtype:'toolbar',

dock:'bottom',

items:[{

xtype:'button',text:'展开节点',id:'allopen'

},{

xtype:'button',text:'收起节点',id:'allclose'

}]

}],

store:treestore,

listeners:{

'itemclick':function(view,re){

if(re.data.leaf==false){

return;

}else{

alert(re.data.id);

}

},

'itemcontextmenu':function(node,e){

var nodemenu=new Ext.menu.Menu({

items:[{

text:"新增组织机构",

icon:'images/add.gif',

iconCls:'leaf',

handler:function(){

alert("新增");

}

},{

text:"编辑组织机构",

icon:'images/leaf.gif',

iconCls:'leaf',

handler:function(){

alert("编辑");

}

},{

text:"删除组织机构",

icon:'images/delete.gif',

iconCls:'leaf',

handler:function(){

alert("删除");

}

}]

});

nodemenu.show();

}

}

});

treePanel=Ext.create("AM.view.treeView",{});

为什么树的右键菜单 显示 在中间去了,而不是直接在单击节点位置显示

已解决

原因: EXT3.0的 显示菜单的事件是 xxx.show(e.getXY());

4.0 木有这个方法。只有showBy(),和show()

解决办法:把你的floating:false改成floating:true就可以了跟以前一样用了showAt了 ,下面贴出修改后代码:

Ext.define("AM.view.treeView",{

extend:"Ext.tree.Panel",

title: "组织机构列表",

frame: true,

region: "west", //呈现在西边,即是左边

width: 210,

margin: "1 0 0 3",

collapsible: true, //是否可以收缩

id:"treeID",

border : true,

rootVisible: true,

padding:"0 0 0 0",

dockedItems:[{

xtype:'toolbar',

dock:'bottom',

items:[{

xtype:'button',text:'展开节点',id:'allopen'

},{

xtype:'button',text:'收起节点',id:'allclose'

}]

}],

store:treestore,

listeners:{

'itemclick':function(view, record, items, index, e){

if(record.data.leaf==false){

return;

}else{

Ext.MessageBox.show({

title: '节点操作',

msg: 'itemclick:index=' + index + ",text=" + record.data.text,

icon: Ext.MessageBox.INFO

});

}

},

'itemcontextmenu':function(menutree, record, items, index, e){

e.preventDefault();

e.stopEvent();

var nodemenu=new Ext.menu.Menu({

floating:true,

items:[{

text:"新增组织机构",

icon:'images/add.gif',

iconCls:'leaf',

handler:function(){

alert("新增");

}

},{

text:"编辑组织机构",

icon:'images/leaf.gif',

iconCls:'leaf',

handler:function(){

alert("编辑");

}

},{

text:"删除组织机构",

icon:'images/delete.gif',

iconCls:'leaf',

handler:function(){

alert("删除");

}

}]

});

nodemenu.showAt(e.getXY()); }

}

});

treePanel=Ext.create("AM.view.treeView",{});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: