PDA

View Full Version : add menuitem dynamically inside one menuitem



swiji2000
6 Sep 2012, 4:06 AM
Hi

I need to add item inside the menuitem dynamically.

menu:{
xtype:'menu',
id:'toolMenu',
items:[{

}]
}


Ext.getCmp('toolMenu').add({xtype:'menuitem',id:'submenu1',text:'abc'});

I want to add like following,

Ext.getCmp('submenu1').add([{xtype:'menuitem',id:'submenu2',text:'xyz'}]);

But i am getting the following error:

TypeError: Ext.getCmp("submenu1").add is not a function

please help me to add items here..

Thanks

Farish
6 Sep 2012, 4:17 AM
its because submenu1 is a menuitem and not a menu. menu has method add, menuitem doesn't.

swiji2000
6 Sep 2012, 8:38 PM
Thanks Farish..

Can i add new items dynamically inside the submenu1(menuitem)?

If i use menu, thats is showing empty menuitem in dropdown list.

Please help me.

Thanks.

Farish
6 Sep 2012, 10:56 PM
I am sorry. I dont know any way of adding items to a menuitem; may be its not possible. You can use a menu but you will have to think about some way make it look like a menuitem when it doesnt have any items added to it.

swiji2000
9 Sep 2012, 8:24 PM
Thanks Farish,

I complete that one.