PDA

View Full Version : Context menu for TreePanel is not working in IE9



DineshGudikandula
21 Jan 2014, 6:23 AM
I taken the sample code from sencha docs http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.tree.TreePanel-event-contextmenu to show context menu for treepanel.It is working fine in Chrome , FireFox but it is not working in IE. Any appreciated solution plz.....




newExt.tree.TreePanel (http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.tree.TreePanel)({
title:'My TreePanel', root:newExt.tree.AsyncTreeNode (http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.tree.AsyncTreeNode)({ text:'The Root', children:[{ text:'Child node 1', leaf:true},{ text:'Child node 2', leaf:true}]}), contextMenu:newExt.menu.Menu (http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.menu.Menu)({ items:[{ id:'delete-node', text:'Delete Node'}], listeners:{ itemclick:function(item){switch(item.id){case'delete-node':var n = item.parentMenu.contextNode;if(n.parentNode){ n.remove();}break;}}}}), listeners:{ contextmenu:function(node, e){// Register the context node with the menu so that a Menu Item's handler function can access// it via its parentMenu (http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.menu.BaseItem-property-parentMenu) property. node.select();var c = node.getOwnerTree().contextMenu; c.contextNode = node; c.showAt(e.getXY());}}});

Thanks in advance ...... :-)

DineshGudikandula
22 Jan 2014, 1:28 AM
I got solution....



new Ext.tree.TreePanel({
title: 'My TreePanel',
renderTo:Ext.getBody(),
height:250,
root: new Ext.tree.AsyncTreeNode({
expanded : true,
text: 'The Root',
children: [
{ text: 'Child node 1', leaf: true },
{ text: 'Child node 2', leaf: true }
]
}),
contextMenu: new Ext.menu.Menu({
items: [{
id: 'delete-node',
text: 'Delete Node'
}],
listeners: {
itemclick: function(item) {
switch (item.id) {
case 'delete-node':
var n = item.parentMenu.contextNode;
if (n.parentNode) {
n.remove();
}
break;
}
}
}
}),
listeners: {
afterrender: function(node, e) {
this.getTreeEl().on({
contextmenu:{scope:this, fn:function( eveObj, ele, option ){

node = this.root.findChild('text', ele.innerText);
var c = this.contextMenu;
c.contextNode = node;
c.showAt(eveObj.getXY());
}, stopEvent:true}
});
}
}
});




Thanks...

Gary Schlosberg
24 Jan 2014, 4:07 PM
Glad to hear you found a solution, and thanks for sharing it with the community.