PDA

View Full Version : Creating sub menu using ExtJS 4.1



Pravin.Pawar
28 Aug 2012, 2:41 AM
Hi,

I want to create sub menu items using ExtJS 4.1. I saw following sample example -


Ext.create (http://docs-devel.sencha.com/ext-js/4-1/#%21/api/Ext-method-create)('Ext.menu.Menu (http://docs-devel.sencha.com/ext-js/4-1/#%21/api/Ext.menu.Menu)', { width: 100, height: 100, floating: false, // usually you want this set to True (default) renderTo: Ext.getBody (http://docs-devel.sencha.com/ext-js/4-1/#%21/api/Ext-method-getBody)(), // usually rendered by it's containing component items: [{ text: 'File', iconCls: 'add16' },{ text: 'text item' },{ text: 'Exit', plain: true }] });

In above example; I want to show 'Open' menu inside 'File' i.e. sub menu. I went through sample examples on sencha.com somehow do NOT get any such example.

Please let me know if you guys have any idea.

Thanks, Pravin

evant
28 Aug 2012, 2:49 AM
There is an example, under /examples/menu in the download.

You mustn't have looked too hard!

sword-it
28 Aug 2012, 4:41 AM
Hi Pravin.Pawar ,
Try the code given below:



Ext.create('Ext.menu.Menu', {
width: 100,
plain: true,
floating: false,
renderTo: Ext.getBody(),
items: [{
text: 'File',
menu:{
items:[
{
text: 'New'
},
{
text: 'open'
}
]
}
},
{
text: 'Edit'
}]
});

Pravin.Pawar
28 Aug 2012, 7:06 AM
Thanks for quick help.. that is what I was looking for :)