The Menu control displays a collection of expandable menu items, arranged vertically. The image below shows a menu that is an instance of the MindFusion.Common.UI.Menu class:

The top-level menu items are stored in the Menu.items collection. Each MenuItem might contain child items, which are accessible through the MenuItem.items property. Menu items can be added and removed programmatically by using the add and remove methods of the corresponding collection.
JavaScript
Copy Code
|
|---|
var menu = new ui.Menu(document.getElementById("links")); var menuItem = new ui.MenuItem("Start", "index.html"); |
JavaScript
Copy Code
|
|---|
var menu = new ui.Menu(document.getElementById("links")); var data = [ menu.fromObject(data); |
Menu items, which contain child items, are expanded on mouse over and collapsed on mouse out. You can specify the number of milliseconds to wait before collapsing an item by setting the closeTimeout property.
The control supports lazy loading, which is enabled by default, meaning that child items DOM will not be created until their parent item is expanded. The full list of menu items (loaded and not) can be accessed through the flatItems property and the currently loaded menu items - though the loadedItems property. Lazy loading can be switched off by setting the loadOnDemand property to false.
JavaScript
Copy Code
|
|---|
menu.loadOnDemand = false; if(menu.loadedItems.count() > 30) |
Important events for the Menu control include:
JavaScript
Copy Code
|
|---|
menu.itemClick.addEventListener(handleMenuClick); function handleMenuClick(sender, args) |
The items data can be serialized to a JSON string via the toJson method and deserialized from a JSON string via the fromJson method.
The MenuItem class represents an expandable list item. The collection of child items is accessible through the MenuItem.items property. A menu item displays the text, specified by its title property, and, optionally, an icon, specified by its imageSrc property, or its content can be set to a custom HTML string via its template property. The menu item title can also serve as a link to an URL, specified by the href property.
JavaScript
Copy Code
|
|---|
var menu = new ui.Menu(document.getElementById("links")); var menuItem = new ui.MenuItem("Start", "index.html"); |