PopupMenuItem Class

An item of the Spreadsheet’s context menu.

Declaration

class PopupMenuItem

Remarks

Example

For a full example, see Spreadsheet - Context Menu Customization demo.

function addCustomMenuItem(menuItems, command) {
   var item = new PopupMenuItem(command.name, command.text, null, null);
   menuItems.Add(item);
}        

Properties

beginGroup Property

Specifies whether the current menu item starts a group.

Declaration

beginGroup: boolean

Property Value

Type Description
boolean

true, if the current menu item starts a group; otherwise, false.

Remarks

Use the beginGroup property to control whether a specific separator should appear before the current menu item to separate it from other menu items.

disabled Property

Indicates whether the menu item is disabled.

Declaration

disabled: boolean

Property Value

Type Description
boolean

true, if the item is disabled; otherwise, false.

Remarks

When the disabled property is set to true, the menu item doesn’t respond to end-user interactions, such as mouse hovering or clicks.

name Property

The unique identifier name for the current menu item.

Declaration

name: string

Property Value

Type Description
string

The item’s unique identifier name.

Remarks

The name property specifies the unique identifier name for the current menu item. You can use this property to obtain a particular item specified by its unique identifier name (via the getByName(name) method) rather than by its index and display text.

parent Property

Gets the immediate parent menu item to which the current menu item belongs.

Declaration

parent: PopupMenuItem

Property Value

Type Description
PopupMenuItem

An object that is the menu item’s immediate parent.

Remarks

Use the parent property to identify and access the immediate parent menu item which owns the current menu item.

template Property

Specifies an item template that is used to render this item only.

Declaration

template: any

Property Value

Type Description
any

The template content.

Remarks

spreadsheet.popupMenuShowing.addHandler(function(s, e) {
    if(e.menuType === DevExpress.AspNetCore.Spreadsheet.PopupMenuType.Cell) {
        var item = new DevExpress.AspNetCore.Spreadsheet.PopupMenuItem("ItemWithTemplate", "Item with template", null, null);
        item.template = function(itemData, itemIndex, itemElement) {
            itemElement.append(" [" + itemIndex + "] <i style='margin-left:5px'>" + itemData.text + "</i>");
        }
        e.menuItems.clear();
        e.menuItems.Add(item);
    }
}
See Also

text Property

Specifies the text content of the current menu item.

Declaration

text: string

Property Value

Type Description
string

The menu item’s text content.

Methods

getItem(index) Method

Returns the menu item’s sub-item with the specified index.

Declaration

getItem(
    index: number
): PopupMenuItem

Parameters

Name Type Description
index number

The index of the sub-item within a collection of the current menu item’s submenu items.

Returns

Type Description
PopupMenuItem

The found sub-item.

getItemByName(name) Method

Returns the menu item’s sub-item with the specified name property value.

Declaration

getItemByName(
    name: string
): PopupMenuItem

Parameters

Name Type Description
name string

The name property value of the sub-item to find.

Returns

Type Description
PopupMenuItem

The found sub-item.

getItemCount Method

Returns the total number of the menu item’s child items.

Declaration

getItemCount(): number

Returns

Type Description
number

The total number of the current menu item’s immediate sub-items.

getSubItems Method

Gets a collection that contains the submenu items of the current menu item.

Declaration

getSubItems(): PopupMenuItemCollection

Returns

Type Description
PopupMenuItemCollection

An object that contains the submenu items of the current menu item.