Class MainMenu

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

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)

Examples

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

Parameters

Type Name Description
String label The label of the group
String image URL to the actual file.

Returns

Type Description
Void

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)

Examples

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

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

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)

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'");

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

addItem(String,String)

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

Declaration

Void addItem(String label, String url)

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);

Parameters

Type Name Description
String label The label of the menu item
String url

Returns

Type Description
Void

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)

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);

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

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)

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);

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

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)

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);

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

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)

Examples

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

Parameters

Type Name Description
Integer index

Returns

Type Description
Void

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)

Examples

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

Parameters

Type Name Description
Integer group

Returns

Type Description
String

getGroupIndex()

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

Declaration

Integer getGroupIndex(String label)

Examples

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

Parameters

Type Name Description
String label Group label (ID).

Returns

Type Description
Integer The position of a specific group in the main menu.

getItemId(Integer,Integer)

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

Declaration

String getItemId(Integer group, Integer pos)

Examples

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

Parameters

Type Name Description
Integer group
Integer pos

Returns

Type Description
String The label (ID) of an item.

getItemIndex(Integer,String)

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

Declaration

Integer getItemIndex(Integer group, String label)

Examples

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

Parameters

Type Name Description
Integer group
String label

Returns

Type Description
Integer The position of a specific item.

getNumGroups()

Returns the current number of groups in the main menu.

Declaration

Integer getNumGroups()

Examples

MainMenu menu = getMainMenu();
Integer nGroups = menu.getNumGroups();

Returns

Type Description
Integer

getNumItems(Integer)

Returns the current number of items in the group.

Declaration

Integer getNumItems(Integer group)

Examples

MainMenu menu = getMainMenu();
Integer nItems = menu.getNumItems(2);

Parameters

Type Name Description
Integer group The group.

Returns

Type Description
Integer The number of items in the group.