- Description
- View Code
- Configuration (4)
- Methods (8)
- Events (3)
The Menu widget displays hierarchical data as a multi-level menu. Menus provide rich styling for unordered lists of items, and can be used for both navigation and executing JavaScript commands. Items can be defined and initialized from HTML, or the rich Menu API can be used to add and remove items.
Getting Started
Create a simple HTML hierarchical list of items
<ul id="menu">
<li>Item 1
<ul>
<li>Item 1.1</li>
<li>Item 1.2</li>
</ul>
</li>
<li>Item 2</li>
</ul>Initialize Kendo Menu using jQuery selector
var menu = $("#menu").kendoMenu();Customizing Menu Animations
By default, the Menu uses a slide animation to expand and reveal sub-items as the mouse hovers. Animations can be easily customized using configuration properties, changing the animation style and delay. Menu items can also be configured to open on click instead of on hover.
Changing Menu animation and open behavior
$("#menu").kendoMenu({
animation: {
open : {effects: fadeIn},
hoverDelay: 500
},
openOnClick: true
});Dynamically configuring Menu items
The Menu API provides several methods for dynamically adding or removing Items. To add items, provide the new item as a JSON object along with a reference item that will be used to determine the placement in the hierarchy.
A reference item is simply a target Menu Item HTML element that already exists in the Menu. Any valid jQuery selector can be used to obtain a reference to the target item. For examples, see the Menu API demos. Removing an item only requires a reference to the target element that should be removed.
Dynamically add a new root Menu item
var menu = $("#menu").kendoMenu().data("kendoMenu");
menu.insertAfter(
{ text: "New Menu Item" },
menu.element.children("li:last")
);No code
-
append(item, referenceItem)Appends a Menu item in the specified referenceItem's sub menuExample
menu.append( [{ text: "Item 1" }, { text: "Item 2" }], referenceItem );Parameters
-
item: Selector - Target item, specified as a JSON object. Can also handle an array of such objects.
-
referenceItem: Item - A reference item to append the new item in
-
-
close(element)Closes the sub menu of the specified Menu item/sExample
menu.close("#Item1");Parameters
-
element: Selector - Target item selector.
-
-
disable(element)Disables a Menu itemParameters
-
element: Selector - Target element
-
-
enable(element, enable)Enables/disables a Menu itemParameters
-
element: Selector - Target element
-
enable: Boolean - Desired state
-
-
insertAfter(item, referenceItem)Inserts a Menu item after the specified referenceItemExample
menu.insertAfter( [{ text: "Item 1" }, { text: "Item 2" }], referenceItem );Parameters
-
item: Selector - Target item, specified as a JSON object. Can also handle an array of such objects.
-
referenceItem: Selector - A reference item to insert the new item after
-
-
insertBefore(item, referenceItem)Inserts a Menu item before the specified referenceItemExample
menu.insertBefore( [{ text: "Item 1" }, { text: "Item 2" }], referenceItem );Parameters
-
item: Selector - Target item, specified as a JSON object. Can also handle an array of such objects.
-
referenceItem: Selector - A reference item to insert the new item before
-
-
open(element)Opens the sub menu of the specified Menu item/sExample
menu.open("#Item1");Parameters
-
element: Selector - Target item selector.
-
-
remove(element)Removes the specified Menu item/s from the MenuExample
menu.remove("#Item1");Parameters
-
element: Selector - Target item selector.
-