-
28 Apr 2008 2:28 AM #1
How to add a submenu to a menu item dynamicly?
How to add a submenu to a menu item dynamicly?
Just like the title, I want to add a submenu to a menu item dynamicly, but I can't find a method like "addMenu" or "addItem" in the Ext.menu.Item apis.
How to do it?
my extjs version is "2.0.2".
thanks! any response will be appreciated.
-
28 Apr 2008 5:26 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
menu items are the last stop for a menu. You'll need to add menu's to your menu in order to add stuff to child nodes.

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
14 Apr 2009 1:32 AM #3
Could you post some sample code for this? I'm having trouble creating a nested set of menus. Thanks!
-
14 Apr 2009 1:44 AM #4
Nevermind, found it!
I was looking for the "menu" config property of the "Item" class. Since this is only settable at object creation time (and not later through a method), I suppose it's an implied requirement that the submenus are built before the parent menu.
For those who may be interested:
I have a Java tree structure (represented as a map of maps). I serialize it using Jabsorb/JSON-RPC, then create extjs menus (& submenus) using the following javascript method:
Code:function buildMenu(theMenu, theTree) { for (var i in theTree) { var subMenu = null if (theTree[i].map) { subMenu = new Ext.menu.Menu({ ignoreParentClicks : true }) buildSuggestionMenu(subMenu, theTree[i].map) } var newItem = { text: i } if (subMenu != null) newItem.menu = subMenu theMenu.add(newItem) } }


Reply With Quote