View Full Version : Desktop Start Sub-Menus

17 Mar 2010, 3:50 PM
I was about to post asking for help on getting sub-menus working in the desktop example without having the modules show up in both the sub-menu and the root start menu. I just figured it out for myself so I thought I would share. I'd also like to hear other solutions if you have any.

All modules must be added to the getModules() method like so:

getModules : function(){
var modules = []
modules.push(new MyDesktop.MembersMenu());
modules.push(new MyDesktop.NewsletterMenu());
modules.push(new MyDesktop.ArticleMenu());
modules.push(new MyDesktop.PagesMenu());
modules.push(new MyDesktop.Members());
modules.push(new MyDesktop.Page());
modules.push(new MyDesktop.ViewPages());
modules.push(new MyDesktop.Newsletter());
modules.push(new MyDesktop.ViewNewsletters());
modules.push(new MyDesktop.Groups());
modules.push(new MyDesktop.Categories());
modules.push(new MyDesktop.Navigation());
modules.push(new MyDesktop.Article());
modules.push(new MyDesktop.ViewArticles());
return modules;

I created the Sub-Menu modules like this:

MyDesktop.MembersMenu = Ext.extend(Ext.app.Module, {
init : function(){
this.launcher = {
text: 'Members',
iconCls: 'icon-members',
handler: function() {
return false;
menu: (function()
var subMenuModule = [];

text: 'View Members',
handler :function(){
scope: this
text: 'Groups',
handler : function(){
scope: this

return subMenuModule;

At this point, you will have the duplicate entries in the start menu for modules that are in sub-menu's (1 in the root menu and 1 in the sub-menu). I resolved this by editing the initModules() method to search an array consisting of module id's that you do not want to be added to the root menu (this can of course be changed to add only these modules to the root menu instead of ignore them):

initModules : function(ms)
var aChildModules = new Array(

var aChildModulesToStr = aChildModules.toString();

for(var i = 0, len = ms.length; i < len; i++)
var m = ms[i];
if(aChildModulesToStr.search(m.id) < 0)
m.app = this;

I hope this helps someone!