UI Widgets Menu

A menu widget.

Included in: dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/menu
Menu interactive configuration
Copy code
$("#menu").dxMenu({
});

The dxMenu widget displays a single-level or multi-level menu that performs an action when an item is clicked.

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxMenu jQuery plug-in.

    HTML
    <div id="menu"></div>
    JavaScript
    var menuItems = [
        { text: "Hide" },
        { text: "Delete" },
        {
            text: "Clipboard",
            items: [
                { text: "Copy text" },
                { text: "Clear text" },
                { text: "Paste text" }
            ]
        }
    ];
    $("#menu").dxMenu({
        items: menuItems
    });
  • Knockout
    Add a div element and apply the dxMenu binding to this element.

    HTML
    <div data-bind="dxMenu: {
        items: menuItems
    }"></div>
  • AngularJS
    Add a div element and apply the dx-menu directive to this element.

    HTML
    <div dx-menu="{
        items: menuItems
    }"></div>

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the Installation article.

You can find detailed information on the principles of working with the widget in the dxMenu section of the Menu Widgets article.

View Demo

Watch Video

Show Example:
AngularJS
Knockout
jQuery
<div class="demo-page" ng-controller="demoController">
    <div dx-menu="{ items: menuItems, onItemClick: itemClicked }"></div>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.menuItems = [
        {
            text: "Tutorials",
            items: [
                { text: "VS Integration" },
                { text: "UI Widgets" },
                { text: "Data Visualization" },
                { text: "Data Layer" }
            ]
        },
        {
            text: "Guides",
            items: [
                { text: "Demos Inside" },
                { text: "UI Widgets" },
                { text: "Data Visualization" },
                { text: "Themes" },
                { text: "Common" }
            ]
        },
        {
            text: "Reference",
            items: [
                { text: 'Data Library' },
                { text: 'UI Widgets' },
                { text: 'Data Visualization Widgets' },
                { text: 'CSS Classes' },
                { text: 'UI Events' }
            ]
        }
    ];
    $scope.itemClicked = function (data) {
        DevExpress.ui.notify("The \"" + data.itemData.text + "\" item is clicked", "success", 1500);
    }
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
body{
    text-align:center;
}
.demo-page{
    max-width: 400px;
    height: 250px;
    margin: 0 auto;
    background-color: #F0F0F0;
}
<div class="demo-page">
    <div data-bind="dxMenu: { items: menuItems, onItemClick: itemClicked }"></div>
</div>
var myViewModel = {
    menuItems: [
        {
            text: "Tutorials",
            items: [
                { text: "VS Integration" },
                { text: "UI Widgets" },
                { text: "Data Visualization" },
                { text: "Data Layer" }
            ]
        },
        {
            text: "Guides",
            items: [
                { text: "Demos Inside" },
                { text: "UI Widgets" },
                { text: "Data Visualization" },
                { text: "Themes" },
                { text: "Common" }
            ]
        },
        {
            text: "Reference",
            items: [
                { text: 'Data Library' },
                { text: 'UI Widgets' },
                { text: 'Data Visualization Widgets' },
                { text: 'CSS Classes' },
                { text: 'UI Events' }
            ]
        }
    ],
    itemClicked: function (data) {
        DevExpress.ui.notify("The \""+ data.itemData.text +"\" item is clicked", "success", 1500);
    }
}
ko.applyBindings(myViewModel);
body{
    text-align:center;
}
.demo-page{
    max-width: 400px;
    height: 250px;
    margin: 0 auto;
    background-color: #F0F0F0;
}
<div class="demo-page">
    <div id="myMenu"></div>
</div>
$("#myMenu").dxMenu({
    items: [
        {
            text: "Tutorials",
            items: [
                { text: "VS Integration" },
                { text: "UI Widgets" },
                { text: "Data Visualization" },
                { text: "Data Layer" }
            ]
        },
        {
            text: "Guides",
            items: [
                { text: "Demos Inside" },
                { text: "UI Widgets" },
                { text: "Data Visualization" },
                { text: "Themes" },
                { text: "Common" }
            ]
        },
        {
            text: "Reference",
            items: [
                { text: 'Data Library' },
                { text: 'UI Widgets' },
                { text: 'Data Visualization Widgets' },
                { text: 'CSS Classes' },
                { text: 'UI Events' }
            ]
        }
    ],
    onItemClick: function (data) {
        DevExpress.ui.notify("The \""+ data.itemData.text +"\" item is clicked", "success", 1500);
    }
});
body{
    text-align:center;
}
.demo-page{
    max-width: 400px;
    height: 250px;
    margin: 0 auto;
    background-color: #F0F0F0;
}

Configuration

An object defining configuration options for the Menu widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

Default Item Template

This section lists the data source fields that are used in a default item template.

By default, a predefined item template is applied to display the items of this widget. This template is based on certain fields of the data source provided for this widget. Below is the list of these fields. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source.

See Also