ContextMenu

The dxContextMenu widget displays a single- or multi-level context menu. An end user invokes this menu by a right click or a long press.

Included in: dx.webappjs.js, dx.all.js
ContextMenu interactive configuration
Copy Code
Copy to Codepen
$("#contextmenu").dxContextMenu({
});

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

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

  • jQuery
    Use the dxContextMenu jQuery plug-in.

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

    HTML
    <div id="targetElement"></div>
    <div data-bind="dxContextMenu: {
        items: menuItems,
        target: '#targetElement'
    }"></div>
  • AngularJS
    Add a div element and apply the dx-context-menu directive to this element.

    HTML
    <div id="targetElement"></div>
    <div dx-context-menu="{
        items: menuItems,
        target: '#targetElement'
    }"></div>

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries 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 dxContextMenu section of the Menu Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the dxContextMenu 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