ext树节点 右键菜单(叶的和非叶子的邮件菜单不一样)
var leafcontextmenu=new Ext.menu.Menu({
id:'leafcontextmeun',
items:[{text:'二加二等于几',
handler:function(){
alert('别逼我点你');
}
}]
}
);
//右键非叶子节点时弹出的menu
var contextmenu=new Ext.menu.Menu({
id:'leafcontextmeun',
items:[{text:'一加一等于几',
handler:function(){
alert('等于2');
}
}]
}
);
function initTreePanel(treePanel){
var obs = treePanel.objectNames.split(',');
var treepanel = new Ext.tree.TreePanel({
title: treePanel.treeName,
border : false,
rootVisible : false,
autoScroll : true,
loader : new Ext.tree.TreeLoader({
dataUrl : '/InspurGIS/extTreeServlet?treeid='+treePanel.treeid
}),
root : new Ext.tree.AsyncTreeNode({
nodeType: 'async',
text: treePanel.treeName,
draggable:false,
id:obs[0]+'_'+treePanel.treeid,
children:[
{id:obs[0]+'_'+treePanel.treeid, text: treePanel.treeName, leaf:false}
]
}),
listeners : {
'click' : function(n ,e) {
try {
if (n.leaf) {
//onNodeClick(n.text, n.attributes.image);
Inspur.GotoMap.gotoMap(n.attributes.x, n.attributes.y, 1*1/100000, null,mapControl);
}
} catch (e) {
}
},
'contextmenu' :function(node,e){
e.preventDefault();
node.select();
try{
if(node.leaf){
leafcontextmenu.showAt(e.getXY());
}
else{
contextmenu.showAt(e.getXY());
}
}
catch(e)
{
}
}
}
});
id:'leafcontextmeun',
items:[{text:'二加二等于几',
handler:function(){
alert('别逼我点你');
}
}]
}
);
//右键非叶子节点时弹出的menu
var contextmenu=new Ext.menu.Menu({
id:'leafcontextmeun',
items:[{text:'一加一等于几',
handler:function(){
alert('等于2');
}
}]
}
);
function initTreePanel(treePanel){
var obs = treePanel.objectNames.split(',');
var treepanel = new Ext.tree.TreePanel({
title: treePanel.treeName,
border : false,
rootVisible : false,
autoScroll : true,
loader : new Ext.tree.TreeLoader({
dataUrl : '/InspurGIS/extTreeServlet?treeid='+treePanel.treeid
}),
root : new Ext.tree.AsyncTreeNode({
nodeType: 'async',
text: treePanel.treeName,
draggable:false,
id:obs[0]+'_'+treePanel.treeid,
children:[
{id:obs[0]+'_'+treePanel.treeid, text: treePanel.treeName, leaf:false}
]
}),
listeners : {
'click' : function(n ,e) {
try {
if (n.leaf) {
//onNodeClick(n.text, n.attributes.image);
Inspur.GotoMap.gotoMap(n.attributes.x, n.attributes.y, 1*1/100000, null,mapControl);
}
} catch (e) {
}
},
'contextmenu' :function(node,e){
e.preventDefault();
node.select();
try{
if(node.leaf){
leafcontextmenu.showAt(e.getXY());
}
else{
contextmenu.showAt(e.getXY());
}
}
catch(e)
{
}
}
}
});