PDA

View Full Version : object object object has no method 'onadded' when trying to add items to menu list



abhigudi
17 Sep 2014, 1:17 AM
Hi All

I am trying to create a sub menu list for a menu componet dynamically.



//first i am creating the main menu...
toolsMenuItem = Ext.create("Ext.menu.Item", {
text : 'mainmenu',
menu : [subMenuItems]
});
// later then creating the submenu
var SubMenuItem =Ext.create("Ext.menu.Item", {
text : 'submenu1'
});

Ext.getCmp('menutoolbar').add(toolsMenuItem );


the main menu is getting added but the submenu is giving me a error as
Uncaught TypeError: Object [object Object],[object Object],[object Object],[object Object] has no method 'onAdded'

can anyone please help me out to fix this .


Thanks
Abhigudi

basav
17 Sep 2014, 1:51 AM
Check this code :


Ext.create('Ext.menu.Menu', {
width: 150,
margin: '0 0 10 0',
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
text: 'Main Menu1',
menu : {
items : [{
text : 'Sub Menu1'
}]
}
},{
text: 'Main Menu2'
},{
text: 'Main Menu3'
}]
});