View Full Version : Treepanel Context Menu

2 Dec 2010, 4:46 PM
I am context menu for tree panel as follows:

var menu1 = new Ext.menu.Menu({
text:'Add Node',
handler: addHandler

function addHandler(item,e){
Ext.getCmp('tree-panel').getSelectionModel().getSelectedNode().appendChild('New Node');

My code is working fine, but what my requirement is when i right click on node and click Add Node, a child with text New Node should be displayed at end. But now i cannot see that way, just a new node with foldericon is displayed at last. What is wrong with my code?

3 Dec 2010, 4:45 AM
1. You shouldn't rely on the tree selection model. Instead, you should store the current node in the menu, so the item handler can access it.

2. It's appendChild({text: 'New Node'})

3 Dec 2010, 6:59 AM
Thanks!!! Can you please post me the code what exactly it should be...

3 Dec 2010, 7:01 AM
Thanks!!! Could you please post me the code...

3 Dec 2010, 7:04 AM
Thanks... Can you please post some code...