DHTMLX Docs & Samples Explorer

Index
dhtmlxmenu
API Methods

## dhtmlxMenu API Methods

### Init

#### Constructor/Destructor

- dhtmlXMenuObject constructor
- unload destructor

#### Loading Data

- loadXML loads menu data from an xml file and calls onLoadFunction when loading is done
- loadXMLString loads menu data from an xml string and calls onLoadFunction when loading is done
- loadFromHTML loads menu data from an html and calls onLoadFunction when loading is done
- enableDynamicLoading enables dynamic loading of sublevels

#### Icons/Skin

- setIconPath alias for setIconsPath
- setIconsPath defines an url where necessary user embedded icons are located
- setImagePath deprecated, not more used from version 2.1, 90226
- setSkin changes menu skin

#### Hide/Clear

- hide hides any open menu polygons
- clearAll clears all loaded items

#### Common

- setOverflowHeight limits the maximum number of visible items in polygons
- setTopText sets top level additional text (in case of usual menubar)
- setVisibleArea sets the area in which the menu can appear, if the area is not set, the menu will occupy all available visible space
- setAlign sets top level menu align
- setRTL sets right-to-left mode
- setOpenMode sets open mode for the menu
- setWebModeTimeout sets hide menu timeout (web mode only)

### Context Menu

#### Init

- renderAsContextMenu renders menu as contextual

#### Context Menu Zones

- addContextZone adds a contextual zone to a contextual menu
- removeContextZone removes an object from contextual zones list
- isContextZone returns true if an object is used as a contextual zone for the menu

#### Show/Hide

- showContextMenu usercall to show a contextual menu
- hideContextMenu usercall to hide a contextual menu

#### Autohide

- setAutoHideMode sets to false to prevent hiding a contextual menu by a click
- setAutoShowMode sets to false to prevent showing a contextual menu by a click

#### Hide All Mode

- setContextMenuHideAllMode sets to true will hide all opened contextual menu polygons on mouseout
- getContextMenuHideAllMode returns hide all contextual menu mode

### Events

- attachEvent attaches an event handler
- detachEvent removes an event handler
- checkEvent returns true if the event exists

### Items

#### Add/Remove

- addNewSibling adds a new sibling item
- addNewChild adds a new child item
- addNewSeparator adds a new separator
- removeItem removes an item from the menu with all nested sublevels

#### Checkboxes

- addCheckbox adds a new checkbox, sibling|child mode
- setCheckboxState sets checkbox's state (checked/unchecked)
- getCheckboxState returns true if checkbox checked

#### Radiobuttons

- addRadioButton adds a new radio button, sibling|child mode
- setRadioChecked checks a radio button inside the group
- getRadioChecked returns a checked radio button id in the group

#### Common

- getItemType returns item type by id
- getParentId returns parent's id

#### State

- setItemEnabled enables an item
- setItemDisabled disables an item
- isItemEnabled returns true if the item is enabled

#### Visibility

- showItem shows an item
- hideItem hides an item
- isItemHidden returns true if the item is hidden

#### Position

- setItemPosition sets new item's position in the current polygon (moves an item inside the single level)
- getItemPosition returns item's position in the current polygon

#### Text

- setItemText sets text for the item
- getItemText returns item's text

#### Icons

- setItemImage sets an image for the item
- getItemImage returns item's image - array(img, imgDis)
- clearItemImage removes both enabled and disabled item images

#### Tooltips

- setTooltip sets tooltip for a menu item
- getTooltip returns tooltip of a menu item

#### Hrefs

- setHref sets href to item, overwrite old if exists
- clearHref clears item href and back item to default onClick behavior

#### UserData

- setUserData sets userdata for an item
- getUserData returns item's userdata

#### HotKeys

- setHotKey sets menu hot-key (just text label)
- getHotKey returns item's hot-key (just text label)