Show / Hide Table of Contents

Class MainMenu

Used to control the main (left-side) menu of SuperOffice CRM. Customizing the main menu means modifying the corresponding trigger.

Syntax

Constructors

MainMenu()

Initializes a new instance of the MainMenu class.

Declaration
MainMenu

Methods

addGroup(String,String)

Adds a group to the main menu (navigator) with the given label and image. By default, it appends the item to the bottom of the main menu. Use one of the other addGroup variants to specify the exact position or on-click JavaScript code.

Declaration
Void addGroup(String label, String image)
Parameters
Type Name Description
String label

The label of the group

String image

URL to the actual file.

Returns
Type Description
Void
Remarks

The image is specified by the URL to the actual file.

Examples
MainMenu menu = getMainMenu();
menu.addGroup("My label", "http://..../graphics/picture.png");

addGroup(String,String,Integer)

Adds a group to the main menu (navigator) with the given label and image in a specific position. This will shift the index of all subsequent groups. Thus, you should not make assumptions about which slot a group is in.

Declaration
Void addGroup(String label, String image, Integer position)
Parameters
Type Name Description
String label

The label of the group

String image

URL to the actual file

Integer position

The position inside the menu of this group.

Returns
Type Description
Void
Remarks

The image is specified by the URL to the actual file.

Examples
MainMenu menu = getMainMenu();
menu.addGroup("My label2", "http://..../graphics/picture.png", 3);
Add the following javascript code: "window.location='http://www.superoffice.com'"

addGroup(String,String,Integer,String)

Adds a group to the main menu (navigator) with the given label and image in a specific position. This will shift the index of all subsequent groups. Thus, you should not make assumptions about which slot a group is in.

In addition, you can specify on-click JavaScript code. Use this to create clickable menu groups.
Declaration
Void addGroup(String label, String image, Integer position, String onClick)
Parameters
Type Name Description
String label

The label of the group

String image

URL to the actual file

Integer position

The position inside the menu of this group

String onClick

JavaScript that is executed when clicking the group.

Returns
Type Description
Void
Remarks

The image is specified by the URL to the actual file.

Examples
MainMenu menu = getMainMenu();
menu.addGroup("My label", "http://..../graphics/picture.png");
menu.addGroup("My label2", "http://..../graphics/picture.png", 3, "window.location='http://www.superoffice.com'");

addItem(String,String)

Adds an item to the SuperOffice main menu (navigator).

Declaration
Void addItem(String label, String url)
Parameters
Type Name Description
String label

The label of the menu item

String url
Returns
Type Description
Void
Examples
MainMenu menu = getMainMenu();
menu.addItem("List equipment", getProgram(1) + "&action=listExtraTable&extraTable=y_equipment");

menu.addItem("New unit", getProgram(1) + "&action=editExtraTableEntry&extraTable=y_equipment", 1, 1);

addItem(String,String,Integer,Integer)

Adds an item to the SuperOffice main menu (navigator).

Declaration
Void addItem(String label, String url, Integer group, Integer position)
Parameters
Type Name Description
String label

The label of the menu item

String url
Integer group

Optional. Which header this item belongs to

Integer position

Optional. The position inside the group of this item.

Returns
Type Description
Void
Examples
MainMenu menu = getMainMenu();
menu.addItem("List equipment", getProgram(1) + "&action=listExtraTable&extraTable=y_equipment");

menu.addItem("New unit", getProgram(1) + "&action=editExtraTableEntry&extraTable=y_equipment", 1, 1);

addItem(String,String,Integer,Integer,String,String,String)

Adds an item to the SuperOffice main menu (navigator).

Declaration
Void addItem(String label, String url, Integer group, Integer position, String onClick, String itemId, String target)
Parameters
Type Name Description
String label

The label of the menu item

String url
Integer group

Optional. Which header this item belongs to

Integer position

Optional. The position inside the group of this item

String onClick

Optional. JavaScript that is executed when clicking the item

String itemId

Optional. A programmatic ID for the item

String target

Optional. The target attribute of the link.

Returns
Type Description
Void
Examples
MainMenu menu = getMainMenu();
menu.addItem("List equipment", getProgram(1) + "&action=listExtraTable&extraTable=y_equipment");

menu.addItem("New unit", getProgram(1) + "&action=editExtraTableEntry&extraTable=y_equipment", 1, 1);

addItem(String,String,Integer,Integer,String,String,String,String)

Adds an item to the SuperOffice main menu (navigator).

Declaration
Void addItem(String label, String url, Integer group, Integer position, String onClick, String itemId, String target, String iconUrl)
Parameters
Type Name Description
String label

The label of the menu item

String url
Integer group

Optional. Which header this item belongs to

Integer position

Optional. The position inside the group of this item

String onClick

Optional. JavaScript that is executed when clicking the item

String itemId

Optional. A programmatic ID for the item

String target

Optional. The target attribute of the link

String iconUrl

Optional. URL of a custom icon.

Returns
Type Description
Void
Remarks

The image is specified by the URL to the actual file.

Examples
MainMenu menu = getMainMenu();
menu.addItem("List equipment", getProgram(1) + "&action=listExtraTable&extraTable=y_equipment");

menu.addItem("New unit", getProgram(1) + "&action=editExtraTableEntry&extraTable=y_equipment", 1, 1);

clear()

Clears all the contents of the menu.

Declaration
Void clear()
Returns
Type Description
Void

deleteGroup(Integer)

Removes the group at the given index (starts at 0) from the main menu.

Declaration
Void deleteGroup(Integer index)
Parameters
Type Name Description
Integer index
Returns
Type Description
Void
Remarks

Verify that you're removing the correct group by checking with getGroupId() what's in that slot first.

Examples
Integer pos = 3;
MainMenu menu = getMainMenu();
if (menu.getGroupId(pos) == "my label") {
  menu.deleteGroup(pos);
}

deleteItem(Integer,Integer)

Removes the item at the given index from the group.

Declaration
Void deleteItem(Integer group, Integer index)
Parameters
Type Name Description
Integer group
Integer index
Returns
Type Description
Void

getGroupId(Integer)

Returns the label (ID) of a group in the main menu given its position.

Declaration
String getGroupId(Integer group)
Parameters
Type Name Description
Integer group
Returns
Type Description
String
Remarks

The IDs are unique strings starting at zero.

Examples
MainMenu menu = getMainMenu();
String label = menu.getGroupId(4);

getGroupIndex()

Returns the position of a specific group in the main menu given its label (ID)

Declaration
Integer getGroupIndex(String label)
Parameters
Type Name Description
String label

Group label (ID).

Returns
Type Description
Integer

The position of a specific group in the main menu.

Examples
MainMenu menu = getMainMenu();
Integer pos = menu.getGroupIndex("my MITs");

getItemId(Integer,Integer)

Returns the label (ID) of an item in a group given its position.

Declaration
String getItemId(Integer group, Integer pos)
Parameters
Type Name Description
Integer group
Integer pos
Returns
Type Description
String

The label (ID) of an item.

Examples
MainMenu menu = getMainMenu();
String label = menu.getItemId(4,1);

getItemIndex(Integer,String)

Returns the position of a specific item in the group given its label (ID).

Declaration
Integer getItemIndex(Integer group, String label)
Parameters
Type Name Description
Integer group
String label
Returns
Type Description
Integer

The position of a specific item.

Examples
MainMenu menu = getMainMenu();
Integer pos = menu.getItemIndex(2,"secret company");

getNumGroups()

Returns the current number of groups in the main menu.

Declaration
Integer getNumGroups()
Returns
Type Description
Integer
Examples
MainMenu menu = getMainMenu();
Integer nGroups = menu.getNumGroups();

getNumItems(Integer)

Returns the current number of items in the group.

Declaration
Integer getNumItems(Integer group)
Parameters
Type Name Description
Integer group

The group.

Returns
Type Description
Integer

The number of items in the group.

Examples
MainMenu menu = getMainMenu();
Integer nItems = menu.getNumItems(2);
In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top