ContextMenu

The ContextMenu 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.web.js, dx.viz-web.js, dx.all.js
Module: ui/context_menu
Export: default
ContextMenu interactive configuration
Copy Code
Copy to Codepen
$("#contextmenu").dxContextMenu({
});

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

jQuery
JavaScript
HTML
var contextMenuItems = [
    { text: "Hide" },
    { text: "Delete" },
    {
        text: "Clipboard",
        items: [
            { text: "Copy text" },
            { text: "Clear text" },
            { text: "Paste text" }
        ]
    }
];
$(function () {
    $("#contextMenu").dxContextMenu({
        items: contextMenuItems,
        target: "#targetElement"
    });
});
<div id="targetElement"></div>
<div id="contextMenu"></div>
Angular
HTML
TypeScript
<div id="targetElement"></div>
<dx-context-menu
    [items]="contextMenuItems"
    target="#targetElement">
</dx-context-menu>
export class AppComponent {
    contextMenuItems = [
        // ...   
    ];
}
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div id="targetElement"></div>
    <div dx-context-menu="{
        items: contextMenuItems,
        target: '#targetElement'
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.contextMenuItems = [
            // ...   
        ];
    });
Knockout
HTML
JavaScript
<div id="targetElement"></div>
<div data-bind="dxContextMenu: {
    items: contextMenuItems,
    target: '#targetElement'
}"></div>
var viewModel = {
    contextMenuItems: [
        // ...
    ]
};
ko.applyBindings(viewModel);
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().ContextMenu()
    .ID("contextMenu")
    .Target("#targetElement")
    .Items(items => {
        items.Add().Text("Hide");
        items.Add().Text("Delete");
        items.Add().Text("Clipboard").Items(clipboardItems => {
            clipboardItems.Add().Text("Copy text");
            clipboardItems.Add().Text("Clear text");
            clipboardItems.Add().Text("Paste text");
        });
    })
)
<div id="targetElement"></div>
@(Html.DevExtreme().ContextMenu() _
    .ID("contextMenu") _
    .Target("#targetElement") _
    .Items(Sub(items)
        items.Add().Text("Hide")
        items.Add().Text("Delete")
        items.Add().Text("Clipboard").Items(Sub(clipboardItems)
            clipboardItems.Add().Text("Copy text")
            clipboardItems.Add().Text("Clear text")
            clipboardItems.Add().Text("Paste text")
        End Sub)
    End Sub)
)
<div id="targetElement"></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 topics in the Installation section.

View Demo

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the ContextMenu widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

See Also

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