jst4fun
17 Jun 2008, 1:33 AM
Hi,
After searching through forum and also going through the tutorials I was able to create a tree with context menu. Now the problem is how to get the node id on which the context menu option is called. Here is my code
Ext.onReady(function(){
var Tree = Ext.tree;
var tree = new Tree.TreePanel({
el:'tree-div',
useArrows:true,
autoScroll:true,
animate:true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl:'fetchTreeData.php'
})
});
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'Destination',
draggable:false,
id:'source'
});
tree.setRootNode(root);
tree.on('contextmenu', createContext);
var ctxMenu = new Ext.menu.Menu({
id:'copyCtx',
items: [
{
id:'add',
handler:addNode,
text:'Add'
},
{
id:'edit',
handler:editNode,
text:'Edit'
},
{
id:'delete',
handler:deleteNode,
text:'Delete'
}
]
});
function createContext(node, e){
ctxMenu.show(node.ui.getAnchor());
}
tree.render();
root.expand();
function editNode(){
}
function deleteNode(){
}
function addNode(){
}
});
I would like to get the node id to the editNode(), deleteNode() and addNode() functions. How is it possible? Thanks
After searching through forum and also going through the tutorials I was able to create a tree with context menu. Now the problem is how to get the node id on which the context menu option is called. Here is my code
Ext.onReady(function(){
var Tree = Ext.tree;
var tree = new Tree.TreePanel({
el:'tree-div',
useArrows:true,
autoScroll:true,
animate:true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl:'fetchTreeData.php'
})
});
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'Destination',
draggable:false,
id:'source'
});
tree.setRootNode(root);
tree.on('contextmenu', createContext);
var ctxMenu = new Ext.menu.Menu({
id:'copyCtx',
items: [
{
id:'add',
handler:addNode,
text:'Add'
},
{
id:'edit',
handler:editNode,
text:'Edit'
},
{
id:'delete',
handler:deleteNode,
text:'Delete'
}
]
});
function createContext(node, e){
ctxMenu.show(node.ui.getAnchor());
}
tree.render();
root.expand();
function editNode(){
}
function deleteNode(){
}
function addNode(){
}
});
I would like to get the node id to the editNode(), deleteNode() and addNode() functions. How is it possible? Thanks