Default Item Template

This section lists the data source fields that are used in a default template for context menu items.

By default, a predefined item template is applied to display context menu items. This template is based on certain fields of the data source provided for the widget. Below is the list of the fields that take part in a default item template for the dxContextMenu. 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. For details refer to the Customize Widget Item Appearance topic.

disabled

Specifies whether or not the menu item is disabled.

Type: Boolean
Default Value: false

icon

The name of an icon to be displayed on the menu item.

Type: String

This option can take on the name of an icon from the built-in icon library.

iconSrc

A URL pointing to the image to be displayed on the menu item.

Type: String

items

Holds an array of menu items.

Type: Array

When specifying the items field for an item, this item becomes a root item. The child items are displayed using the same default item template as the root items. So specify the fields that take part in the default item template when defining items array objects. Alternatively, you can implement a custom item template. For details, refer to the Customize Widget Item Appearance topic.

NOTE: Each item of the array passed to the items option can include an items field, which takes on an object with the same structure as a root item. Therefore, you can create as many menu levels as you need.

selectable

Specifies whether or not a user can select a menu item.

Type: Boolean
Default Value: false

selected

Specifies whether or not the item is selected.

Type: Boolean
Default Value: false

template

Specifies an item template that should be used to render this item only.

Type: String|function|DOM Node|jQuery
Return Value: String|jQuery
A template name or a template container.

Whether you use a default or a custom template for widget items, you can specify a specific template for a particular item. To do so, set the template field for the data source object of this item. The following types of the specified value are available.

  • Assign a string representing the name of the required template.
  • Assign a jQuery object representing the template's container.
  • Assign a DOM Node representing the template's container.
  • Assign a function that returns the jQuery object or a DOM Node representing the template's container.

To learn more about item templates, refer to the Customize Widget Item Appearance topic.

text

Specifies the text inserted into the item element.

Type: String

visible

Specifies whether or not the menu item is visible.

Type: Boolean
Default Value: true