EXT4 树 右键菜单 显示问题
2012-11-07 18:20
573 查看
转自: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",{});
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",{});
相关文章推荐
- SVN工具更新 tortoisesvn 右键菜单不显示问题
- C#中为DataGrid显示右键菜单与右键切换当前行的问题
- win7 64位svn右键菜单不显示问题
- 解决windows 10 桌面右键时菜单显示出来需要很长时间的问题
- 解决 qtcreator编辑*.ui文件时右键菜单不能正常显示但的问题
- developer express右键菜单显示问题
- C#contextmenustrip长度问题 右键快捷菜单上的文字不能完全显示
- win7 64位svn右键菜单不显示问题
- Win8触屏右键菜单显示不出 Press and Hold WM_GESTURE 问题 csdn
- WIN7系统下安装TortoiseSVN右键菜单不显示问题解决办法
- 解决 qtcreator编辑*.ui文件时右键菜单不能正常显示但的问题
- 解决 qtcreator编辑*.ui文件时右键菜单不能正常显示但的问题
- 最新pydev(3.0)安装后 没有菜单显示的问题
- 怎样将显示隐藏文件的命令添加进右键菜单
- vc 右键菜单显示
- 火狐浏览器兼容右键菜单的问题
- 关于dorado框架datatable处的右键菜单无法根据具体数据实现动态分别显示不同菜单的解决方法
- 解决SecureCRT中文显示乱码和全屏无法显示菜单的问题
- Ext4.1 tree grid的右键菜单
- VIM菜单异常(没有中文显示)和乱码问题解决方案