How to add sub-sub-menus to a google spreadsheet using google app scripts
Asked Answered
S

4

5

Is it possible to add a second level sub-menu (sub-sub-menu) to a Google spreadsheet? I know how to add a menu with a sub-menu but what I need is to add one level more. Thanks.

Summons answered 26/2, 2013 at 0:43 Comment(0)
R
7

You can add a sub-sub-menu now. I believe you should be able to continue to nest multiple menus.

DocumentApp.getUi()
  .createMenu("TopMenu")
  .addItem('Top Item', 'topProgram')
  .addSeparator()
  .addSubMenu(DocumentApp.getUi().createMenu('SubMenu')
              .addItem('Sub Item', 'subProgram')
              .addSubMenu(DocumentApp.getUi().createMenu('Sub Sub Menu')
                          .addItem('SubSub Item', 'subSubProgram')))

  .addToUi();

The idea above would that you create a menu and just added it as a "sub menu". The example below creates the same menu above, but more clearly broken out.

var subSubMenu = DocumentApp.getUi().createMenu('Sub Sub Menu')
                          .addItem('SubSub Item', 'subSubProgram');

var subMenu = DocumentApp.getUi().createMenu('Sub Menu')
                          .addItem('Sub Item', 'subProgram')
                          .addSubMenu(subSubMenu);

var topMenu = DocumentApp.getUi().createMenu('Top Menu')
                          .addItem('Top Item', 'topProgram')
                          .addSubMenu(subMenu);
topMenu.addToUi();
Rittenhouse answered 25/10, 2015 at 21:1 Comment(0)
J
2

Looks like this is not possible. You can take a look at Issue 317, but it doesn't look like it has made any progress in the past 2 years, so don't get too excited. Anyways, you can follow it and see if there are any updates.

Jackass answered 26/2, 2013 at 1:44 Comment(1)
I guess I will have to wait. Meanwhile I will try to separate the features in different spreadsheets. ThanksSummons
S
0

Second tier drop down menus are, IMO, not a great design pattern. You will get better use and it's possible to instead have each parent category as a separate menu with simple lists in each (unless of course you are looking for a gazillion commands).

I'm not looking to diminish your need, but not having it is a win for user experience.

Scold answered 26/2, 2013 at 15:2 Comment(2)
The problem is that I already added 3 (each with 6 to 8 itmes) and I still need to add more. The space in the spreadsheet menu bar is limited, i.e., I can add as many as I want but with 3 or more it starts to look very crowdedSummons
sounds like quite a set of functions. could it be that one or 2 menu items could instead launch a UIApp as a modal dialog and launch the scripts from there?Scold
W
0

It is possible. The key problem is to add menus in the right order to get rid of nasty message "Custom menus must contain at least one item" enter image description here

Whereabouts answered 3/12, 2022 at 15:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.