Search code examples
javascriptextjsextjs3

Ext js 3.4 get node


I have TreePanel with listeners:

listeners: {
        contextmenu: function(node) {
            if(node === tree.getRootNode())
                contextMenu.items.get(1).setDisabled(true);
            else 
                contextMenu.items.get(1).setDisabled(false);
            contextMenu.show(node.ui.getEl());  
        }}

And I have context Menu.

var contextMenu = new Ext.menu.Menu({
    items: [{
        text: 'Add',
        icon: './static/ExtJS/images/default/dd/drop-add.gif',
        handler: function(item, checked){}, {
        text: "Remove",
        icon: "./static/ExtJS/images/default/dd/drop-no.gif",
        handler: function(item){
    }}]
});

How I can get in handler Node where should add new node?


Solution

  • Just store the node somewhere:

    contextMenu.activeNode = node;
    contextMenu.show();
    
    // In the handler
    handler: function(item) {
        var node = item.ownerCt.activeNode
    }