List of Menu Controls

In this article you'll find the controls you can use in dhtmlxMenu. Their descriptions contain lists of attributes and examples of adding the controls into Menu on the fly.

To operate Menu controls, you can use Menu API and Tree Collection API. Check the related article.

MenuItem

MenuItem is a drop-down list of options.

Menu Item

Adding menuItem

You can add a MenuItem control into the menu with the help of the add() method of Tree Collection:

menu.data.add({
    type:"menuItem", value:"Menu", items:[
        { type:"menuItem", value:"Option 1" },
        { type:"menuItem", value:"Option 2" },
        { type:"separator"},
        { type:"menuItem", value:"Option Infinite" }
    ]
});

Attributes

You can provide the following attributes in the configuration object of a MenuItem control:

  • type - (string) the type of a control, set it to "menuItem"
  • id - (string) the id of a control, auto-generated if not set
  • icon - (string) the name of an icon from the used icon font
  • items - (array) an array of children controls (note that all the children should have the type menuItem)
  • value - (string) a value for the menu item
  • hotkey - (string) the name of a keyboard shortcut for a menu item

NavItem

This is a default control for navigation-related components, can contain any other controls as nested items.

Adding NavItem

A navItem can be easily added to a menu with the help of the add() method of Tree Collection:

menu.data.add({
    type:"navItem", value:"My NavItem"
});

Attributes

  • type - (string) the type of a control, set it to "navItem"
  • id - (string) the id of a control, auto-generated if not set
  • css - (string) adds style classes to a navItem
  • value - (string) a value of the navItem
  • tooltip - (string) a tooltip for the navItem
  • count - (number) a badge with a number
  • countColor - (string) the color of a badge with number: "danger" | "secondary" | "primary" | "success"
  • items - (array) an array of nested controls
  • icon - (string) an icon of the navItem
  • size - (string) defines the size of a navItem: "small"|"medium"|"auto"

Adding an icon

A navItem can have an icon which is set through the corresponding option icon:

{
    type:"navItem", value:"Some",
    icon:"dxi-check"
}

Adding a badge with a number

You can add a number badge to the navItem to display information like the number of new messages. The badge is set via the count property:

{
    type:"navItem", value:"Some",
    icon:"dxi-check",
    count:10
}

Showing/hiding a navItem

To hide/show a navItem, you should pass the ID of the navItem to the hide() / show() Menu methods:

menu.show(id);
menu.hide(id);

Enabling/disabling a navItem

Any navItem in the menu can be enabled/disabled:

menu.enable(id);
menu.disable(id);

Setting tooltip

You can add a tooltip to a navItem:

{
    type:"navItem", 
    value:"Click", 
    tooltip:"Click me and find out why"  }

Separator

This is a horizontal (between menu options) or vertical (between menu items) line separating items/groups of items from each other.

Adding Separator

A new Separator can be created with the help of the add() method of Tree Collection:

menu.data.add({
    type:"separator"
});

Attributes

Separator can have two attributes:

  • type - (string) the item type, set it to "separator"
  • id - (string) the ID of a control, automatically generated if you do not set it

Spacer

This item takes space on the toolbar and is used for aligning controls.

DHX Toolbar spacer

Adding Spacer

A new Spacer can be created with the help of the add() method of Tree Collection:

toolbar.data.add({
    type:"spacer"
});

Attributes

Spacer can have two attributes:

  • type - (string) the type of a control, set it to "spacer"
  • id - (string) the ID of a control, automatically generated if you do not set it
Back to top