PDA

View Full Version : create Menu and Sub menu recursively in Extjs



2mailpks
27 Jun 2017, 11:13 PM
0down votefavorite (https://stackoverflow.com/questions/44772848/create-menu-and-sub-menu-recursively-in-extjs#)


Is there way i can create Menu and Submenu recursivesly like tree node creation in Treepanel Extjs
Say i have empty menu items
I read xml input for constructing a Menu and Submenu
my xml look like






Is there way i can create Menu and Submenu recursivesly like tree node creation in Treepanel Extjs


Say i have empty menu items


I read xml input for constructing a Menu and Submenu


my xml look like


<r>
<sub>
<sub1>
<sub 1.1/>
<sub 1.1.1/>
</sub1>
<sub2/>
<sub3>
<sub 3.1>
<sub 3.1.1>
</sub3>
</r>


xml may go any depth ,please provide suggestion

Gary Schlosberg
28 Jun 2017, 5:54 AM
There's nothing build into Ext JS 3 that will create a menu from XML.

2mailpks
28 Jun 2017, 10:14 PM
There's nothing build into Ext JS 3 that will create a menu from XML.


Thanks for your reply Gary Schlosberg, by the way can you help me out how to achieve thus,

i have splitbutton with menu configured as empty array

xtype: "splitbutton",
//text: 'FAQ',
tooltip:'Help',
enableToggle:true,
iconCls : 'help-btn',
hidden: Ext.DomQuery.jsSelect("MENU/ITEM", me.xml).length>=1?false:true,
menu:[],
listeners : {
arrowclick : function () {
var Menunode = Ext.DomQuery.selectNode('MENU',me.xml);
if(this.menu.items.length==0)
this.ownerCt.renderMenu(Menunode,this.menu)
this.menu.showAt(this.getX(),this.getY()*4);

}


when user click arrow i am planning build menu by follwing xml

<MENU>
<ITEM LABEL="FAQ" URL="" clsName="user_guide" HIDDEN='false' handler='newWindow'/>
<ITEM LABEL="Key Contact Information" URL="" clsName="faq-btn" HIDDEN='false' handler='null'>
<ITEM LABEL="someLabel" URL="someURL handler usd to open" clsName="faq-btn" HIDDEN='false' handler='emailHandler'>
<ITEM LABEL="abc" URL="aa" clsName="faq-btn" HIDDEN='false' handler='emailHandler'/>
</ITEM>
</ITEM>
<ITEM LABEL="Training Materials" URL="someURL handler usd to open" clsName="trMaterial" HIDDEN='false' handler='null'>
<ITEM LABEL="System " URL="someURL handler usd to open" clsName="faq-btn" HIDDEN='false' handler='newWindow'/>
<ITEM LABEL="Data " URL="someURL handler usd to open" clsName="faq-btn" HIDDEN='false' handler='newWindow'/>
</ITEM>
</MENU>


where item can be go any depth, i have recursively traverse menu-->item,item-->item if any like that,
if single item it will added to empty menu Array []

else
it will be recursively passed in function at end once all levels passed new item will be added into menu

Thanks in Advance