-2

i am a noob in ext js and stuck with a problem.
i have created an app this is the init function of my controller.

init: function () {
        console.log('initialized filesystem controller');
        this.control({
            'filesystemtree': {
                itemdblclick: this.OpenFile,
                select: this.NodeSelected
            },
            'filesystemtree filesystemmenu button[text="Delete"]': {
                click:this.DeleteButtonClicked
            }
        });
    }

and this is the view with xtype : 'filesystemtree'

Ext.define('IDE.view.fileSystem.List', {
    extend: 'Ext.tree.Panel',
    alias: 'widget.filesystemtree',
    title: 'Navigation2',
    store: 'FileSystems',
    rootVisible: 'false',
    dockedItems: [{
        xtype:'filesystemmenu',
        dock:'top'
    }],
    initComponent: function () {
        console.log('file system tree initializing');
        this.callParent(arguments);
    }
})

and this is the view with xtype:filesystemmenu docked to filesystemtree

Ext.define('IDE.view.fileSystem.FileSystemMenu', {
    extend: 'Ext.toolbar.Toolbar',
    alias: 'widget.filesystemmenu',
    items: [
        {
            xtype: 'splitbutton',
            text: 'Menu',
            menu: new Ext.menu.Menu({
                items: [
                        {
                            text: 'Delete'
                        },
                        {
                            text: 'Copy'
                        },
                        {
                            text: 'Paste'
                        },
                        {
                            text: 'Cut'
                        },
                        {
                            name: 'Rename',
                            xtype: 'textfield',
                            emptyText: 'Enter text to rename'
                        }
                    ]
            })
        },
        {
            text: 'Add Item',
            id:'FSAddItemButton'
        },
        '->',
        {
            xtype: 'box',
            id: 'fileSystemNodeNameLabel'
        }
    ]
})

but in the controller im unable to attach a click event to the delete button present in the filesystemmenu which itself is present as a docked item to the filesystemtree. basically this line in the controller aint working.

'filesystemtree filesystemmenu button[text="Delete"]': {
                click:this.DeleteButtonClicked
            }

what am i doing wrong?

Parv Sharma
  • 12,581
  • 4
  • 48
  • 80

1 Answers1

0

Look at your selector. You're asking it to find a button with the text "Delete", however you don't have any component matching the criteria, because children of menus are Ext.menu.Item by default, so your selector should be:

'filesystemtree filesystemmenu menuitem[text="Delete"]'
Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66