Configuration

An object defining configuration options for the dxContextMenu widget.

activeStateEnabled

A Boolean value specifying whether or not the widget changes its state when interacting with a user.

Type: Boolean
Default Value: true

This option is used when the widget is displayed on a platform whose guidelines include the active state change for widgets.

allowSelectItem

Deprecated

Use the selectionMode option instead.

animation

An object that defines the animation options of the widget.

Type: animation configuration
Default Value: { show: { type: "fade", from: 0, to: 1, duration: 100 }, hide: { type: 'fade', from: 1, to: 0, duration: 100 } }

contentReadyAction

Deprecated

Use the onContentReady option instead.

cssClass

Specifies the name of the CSS class associated with the menu.

Type: String
Default Value: ''

Use this option to customize the current menu in isolation from other menus created on the same page.

Show Example:
AngularJS
Knockout
jQuery

dataSource

A data source used to fetch data to be displayed by the widget.

Default Value: null

You can assign an array directly to this option as well as use the Data Source provided by the DevExtreme library.

To display widget items, a default template can be used. This template is based on the data source fields that are listed in the Default Item Template section of the widget's API. Alternatively, you can implement a custom item template.

See Also

direction

Deprecated

Use the submenuDirection option instead.

disabled

A Boolean value specifying whether or not the widget can respond to user interaction.

Type: Boolean
Default Value: false

Create an observable variable and assign it to this option to specify the availability of the widget at runtime.

Show Example:
AngularJS
Knockout
jQuery

focusStateEnabled

Specifies whether or not the widget can be focused.

Type: Boolean
Default Value: false

height

Specifies the height of the widget.

Type: Number|String|function
Return Value: Number|String
The widget height.
Default Value: undefined

The option can hold a value of the following types.

  • number
    The height of the widget in pixels

  • string
    A CSS measurement of the widget height (e.g., "55px", "80%", "auto" and "inherit")

  • function
    A function returning the widget height (e.g., height:function(){ return baseHeight - 10 + "%"; })

Show Example:
AngularJS
Knockout
jQuery

hiddenAction

Deprecated

Use the onHidden option instead.

hidingAction

Deprecated

Use the onHiding option instead.

hint

Specifies the text of the hint displayed for the widget.

Type: String
Default Value: undefined

hoverStateEnabled

A Boolean value specifying whether or not the widget changes its state when being hovered by an end user.

Type: Boolean
Default Value: true

invokeOnlyFromCode

Specifies whether the context menu can be called only from code or by user interaction as well.

Type: Boolean
Default Value: false

If the invokeOnlyFromCode option is set to true, a browser context menu is displayed when you right click the target element. To display the dxContextMenu widget for this target element, use the visible option.

Show Example:
AngularJS
Knockout
jQuery

itemClickAction

Deprecated

Use the onItemClick option instead.

itemRender

Deprecated

Use the itemTemplate option instead.

itemRenderedAction

Deprecated

Use the onItemRendered option instead.

items

Holds an array of menu items.

Type: Array

To display menu items, a default template can be used. This template is based on certain fields of the item object. Refer to the Default Item Template section to learn which fields are taken into account when creating a default template for items. Alternatively, you can implement a custom item template.

See Also

NOTE: Each item of the array passed to the items option can include the 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.

Show Example:
AngularJS
Knockout
jQuery

itemSelectAction

Deprecated

Use the onSelectionChanged option instead.

A function performed when a widget item is selected.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
itemData: Object
The data that is bound to the selected item.
itemElement: jQuery
An HTML element representing the item.
itemIndex: Number
Specifies the index of the just selected item.
Default Value: null

Assign a function to perform a custom action when a widget item is selected.

Alternatively, you can assign a URL to which the browser will navigate when a widget item is selected.

itemTemplate

The template to be used for rendering items.

Type: String|function|DOM Node|jQuery
Function parameters:
itemData: Object
The item object to be rendered.
itemIndex: Number
The index of the item to be rendered.
itemElement: jQuery
An HTML element of the item to be rendered.
Return Value: String|DOM Node|jQuery
A template name or a template container.
Default Value: "item"
See Also

NOTE: A binding context of an item template is the data source object that corresponds to the currently rendered item. So, you can bind template elements to the item object's fields directly (see the code above). To access another binding context within an item template, use Knockout/Angular binding variables.

onContentReady

A handler for the contentReady event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
Default Value: null

Assign a function to perform a custom action when widget content is ready.

onDisposing

A handler for the disposing event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
Default Value: null

Assign a function to perform a custom action when you dispose of this component.

onHidden

A handler for the hidden event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
Default Value: null

Show Example:
AngularJS
Knockout
jQuery

onHiding

A handler for the hiding event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
cancel: Boolean
Specifies whether or not to cancel the hiding of the widget.
Default Value: null

Show Example:
AngularJS
Knockout
jQuery

onItemClick

A handler for the itemClick event.

Type: function|String
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
itemData: Object
The data that is bound to the clicked item.
itemElement: jQuery
An HTML element of the item.
itemIndex: Number
Specifies the index of the clicked item.
Default Value: null

Assign a function to perform a custom action when a widget item is clicked.

To navigate to a specific URL when the itemClick event fires, assign that URL or the anchor part (#) of that URL directly to this option as a string.

Show Example:
AngularJS
Knockout
jQuery

onItemContextMenu

A handler for the itemContextMenu event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
itemData: Object
The data that is bound to the item.
itemElement: jQuery
An HTML element of the item.
itemIndex: Number
Specifies the index of the item.
Default Value: null

Assign a function to perform a custom action when the right mouse button is clicked when the pointer is over a widget item, or when the "sustained" (also known as a long press) touch action is performed.

onItemRendered

A handler for the itemRendered event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
itemData: Object
The data that is bound to the item to be rendered.
itemElement: jQuery
An HTML element of the item.
itemIndex: Number
Specifies the index of the rendered item.
Default Value: null

Assign a function to perform a custom action after a collection item is rendered.

onOptionChanged

A handler for the optionChanged event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
value: any
Specifies a new value for the option.
Default Value: null

Assign a function to perform a custom action after an option of the component is changed.

onPositioning

A handler for the positioning event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
jQueryEvent: jQuery.Event
Returns a jQuery event that caused the event.
position: position
An object that holds context menu positioning options.
Default Value: null

onSelectionChanged

A handler for the selectionChanged event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
Default Value: null

Assign a function to perform a custom action after a collection item is selected or unselected.

onShowing

A handler for the showing event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
Default Value: null

Show Example:
AngularJS
Knockout
jQuery

onShown

A handler for the shown event.

Type: function
Function parameters:
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element.
Default Value: null

Show Example:
AngularJS
Knockout
jQuery

position

An object defining widget positioning options.

Type: Object
Default Value: { my: 'top left', at: 'top left' }

NOTE: To specify the element against which the context menu will be positioned, use the target option instead of the of field of the position object. If both target and of are specified, target will be used.

Show Example:
AngularJS
Knockout
jQuery

positioningAction

Deprecated

Use the onPositioning option instead.

rtlEnabled

Specifies whether or not the current component supports a right-to-left representation.

Type: Boolean
Default Value: false

If you need to switch the display of this DevExtreme component to right-to-left, enable a specifically designed configuration option - rtlEnabled. When this option is set to true, the text flows from right to left, and the layout the component's elements is reversed. To switch the entire application/site to a right-to-left representation, use the static DevExpress.rtlEnabled field.

Show Example:
AngularJS
Knockout
jQuery

selectedItem

The selected item object.

Type: Object
Default Value: null

selectedItems

An array of currently selected item objects.

Type: Array

selectionByClick

Specifies whether or not an item becomes selected if an end-user clicks it.

Type: Boolean
Default Value: false

selectionMode

Specifies the selection mode supported by the menu.

Type: String
Default Value: none
Accepted Values: 'single'|'none'

showingAction

Deprecated

Use the onShowing option instead.

shownAction

Deprecated

Use the onShown option instead.

showSubmenuMode

Specifies the user interaction by which submenus are shown.

Type: String
Default Value: 'onHover'
Accepted Values: 'onHover'|'onHoverStay'|'onClick'

Show Example:
AngularJS
Knockout
jQuery

submenuDirection

Specifies the direction at which submenus are displayed.

Type: String
Default Value: 'auto'
Accepted Values: 'auto'|'right'|'left'

By default, the submenus of the context menu are displayed so that they are visible totally, based on the widget location on the page. Use the submenuDirection option to display submenus to the left or to the right from the context menu.

tabIndex

Specifies the widget tab index.

Type: Number
Default Value: 0

target

The target element associated with a popover.

Default Value: window

Specify this option to indicate the element for which the context menu will be invoked. This option can take on one of the following values.

JavaScript
//CSS selector
target: '#targetElement';

//jQuery wrapper
target: $('#targetElement');

//DOM element
target: document.getElementById('targetElement');

To align the context menu near this element, use the position option.

Show Example:
AngularJS
Knockout
jQuery

visible

A Boolean value specifying whether or not the widget is visible.

Type: Boolean
Default Value: false

Use this option to display/hide a context menu in code.

Show Example:
AngularJS
Knockout
jQuery

width

Specifies the width of the widget.

Type: Number|String|function
Return Value: Number|String
The widget width.
Default Value: undefined

The option can hold a value of the following types.

  • numeric
    The widget width in pixels.
  • string
    A CSS measurement of the widget width (e.g., "55px", "80%", "auto" and "inherit").
  • function
    The function returning the widget width. For example, see the following code.

    JavaScript
    width: function () { 
        return baseWidth - 10 + "%";
    }
Show Example:
AngularJS
Knockout
jQuery