PDA

View Full Version : Menu not available in panel items array



gemerson
5 Dec 2012, 1:10 PM
I'm creating a menu within a tree panel (code below) config but can't query for it. I checked the items array and alll it contained was a tree view. How a can the menu be created? Thanks.



Ext.define('MyApp.view.ProjectsPanel', {
extend: 'Ext.tree.Panel',
alias: 'widget.projectsPanel',


autoRender: true,
autoShow: true,
width: 200,
resizable: true,
title: 'Projects',
store: 'ProjectsCollection',
displayField: 'label',


initComponent: function() {
var me = this;


Ext.applyIf(me, {
viewConfig: {


},
items: [
{
xtype: 'menu',
floating: true,
itemId: 'folder-click-menu',
width: 120,
items: [
{
xtype: 'menuitem',
text: 'New',
listeners: {
click: {
fn: me.onMenuitemClick,
scope: me
}
}
},
{
xtype: 'menuitem',
text: 'Delete'
}
]
}
],
listeners: {
beforerender: {
fn: me.onTreepanelBeforeRender,
scope: me
}
}
});


me.callParent(arguments);
},


onMenuitemClick: function(item, e, options) {
var projectCreationDialog =
Ext.create('MyApp.view.NewProjectsNodeForm');
projectCreationDialog.show();
},


onTreepanelBeforeRender: function(abstractcomponent, options) {
abstractcomponent.store.load();
}


});

mitchellsimoens
7 Dec 2012, 8:12 AM
The menu shouldn't be an item, you should create the instance, save it as a property and hide/show it. REmember on destroy you need to destroy the menu.

gemerson
7 Dec 2012, 8:20 AM
Fair enough. In the future, maybe Architect should disallow dragging a menu into a panel. Thanks.