UI Widgets DropDownMenu

A drop-down menu widget.

Type: Object

This widget is a UI element (a button or a toolbar item) that displays a drop-down menu when clicked.

To create a dxDropDownMenu widget, add a div element with dxDropDownMenu Knockout binding within the body of the required view.

HTML
<div data-bind="dxDropDownMenu: { buttonText: 'Show menu', dataSource: dropDownMenuData, itemClickAction: menuItemClicked }"></div>

The drop-down menu items are loaded from an array specified via the dataSource configuration option. You can specify a DataSource object, a simple array, or an array of objects as the widget data source.

JavaScript
var dropDownMenuData = [
    "Copy",
    "Cut",
    "Clear"
];

Declare a function that processes a menu item click, and assign it to the itemClickAction configuration option.

JavaScript
var menuItemClicked = function(e){
    alert(e.itemData + "item clicked");
};

Note that you can access the clicked item text from the itemData field of the object passed as an argument to the itemClickAction function.

To display widget items, a default template is applied based on the following fields of the data source item objects.

  • disabled
    Specifies whether or not the widget item is disabled.
  • visible
    Specifies whether or not the widget item is visible.
  • html
    Specifies the html code inserted into the item element.
  • text
    Specifies the text inserted into the item element.

You can introduce a custom template for the widget's items. For this purpose, add a div element with the data-options attribute set to dxTemplate. Assign item to the template name. In this instance, the template will be applied automatically. See the Customize Widget Item Appearance topic to learn more about templates.

Refer to the Add a Widget documentation section to learn how to create widgets in detail.

Show Example:
jQuery
<div data-bind="dxDropDownMenu: { buttonText: 'Show menu', dataSource: dropDownMenuData, itemClickAction: menuItemClicked }"></div>
dropDownMenuData = [
    "Copy",
    "Cut",
    "Clear"
];
menuItemClicked = function(e){
    DevExpress.ui.notify( e.itemData + " item clicked", "success", 2000 );
};
body {
  text-align: center;
}
#menu {
  margin-top: 25px;
}

Configuration

An object defining configuration options for the dxDropDownMenu widget.

Methods

This section describes methods that can be used to manipulate a widget.

Events

This section describes events fired by this component.