Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PopupMenuItemCollection Class

A collection of items in the Spreadsheet’s context menu.

#Declaration

TypeScript
class PopupMenuItemCollection
See Also

#Methods

#add(item) Method

Adds the specified menu item to the end of the collection.

#Declaration

TypeScript
add(
    item: PopupMenuItem
): void

#Parameters

Name Type Description
item PopupMenuItem

The item to be added to the collection.

#Remarks

For a full example, see Context Menu Customization demo.

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

#clear Method

Removes all menu items from the collection.

#Declaration

TypeScript
clear(): void

#Remarks

For a full example, see Context Menu Customization demo.

function SpreadsheetPopupMenuShowing(s, e) {
    if (e.menuType === PopupMenuType.Cell) {
        e.menuItems.Clear();
        if (needToAddCustomMenuItems(s)) {
            if (isSelectedCellOfType(s, currencyColumns))
                addCustomMenuItem(e.menuItems, convertCurrencyCommand);
            if (isSelectedCellOfType(s, discountColumns))
                addCustomMenuItem(e.menuItems, discountCommand);
            if (isSelectedCellOfType(s, weightColumns))
                addCustomMenuItem(e.menuItems, convertUnitsCommand);
        }
    }
    else if (e.menuType !== PopupMenuType.AutoFilter)
        e.cancel = true;
}

#get(index) Method

Returns a menu item specified by its index in the collection.

#Declaration

TypeScript
get(
    index: number
): PopupMenuItem

#Parameters

Name Type Description
index number

The zero-based index of the item.

#Returns

Type Description
PopupMenuItem

An object that is a menu item with the specified index.

#getByName(name) Method

Gets an item specified by its name.

#Declaration

TypeScript
getByName(
    name: string
): PopupMenuItem

#Parameters

Name Type Description
name string

The name property value of a menu item.

#Returns

Type Description
PopupMenuItem

An item with the specified name.

#getCount Method

Returns the total number of menu items in the collection.

#Declaration

TypeScript
getCount(): number

#Returns

Type Description
number

The total number of menu items.

#insert(index, item) Method

Adds the specified item to the specified position within the collection.

#Declaration

TypeScript
insert(
    index: number,
    item: PopupMenuItem
): void

#Parameters

Name Type Description
index number

The zero-based index at which the specified item should be inserted.

item PopupMenuItem

An item to insert.

#remove(index) Method

Removes a menu item specified by its index within the collection.

#Declaration

TypeScript
remove(
    index: number
): void

#Parameters

Name Type Description
index number

The index of the menu item

#removeByName(name) Method

Removes a menu item specified by its name.

#Declaration

TypeScript
removeByName(
    name: string
): void

#Parameters

Name Type Description
name string

The name property value of a menu item.