v7.3.0

CellMenu
Feature

Right click to display context menu for cells. To invoke the cell menu in a keyboard-accessible manner, use the Space key when the cell is focused.

Default cell menu items

The Cell menu feature provides only one item by default:

Reference Text Weight Description
removeRow Delete 100 Delete row record

And all the other items are populated by the other features:

Reference Text Weight Feature Description
cut Cut record 110 RowCopyPaste Cut row record
copy Copy record 120 RowCopyPaste Copy row record
paste Paste record 130 RowCopyPaste Paste copied row records
search Search for value 200 Search Search for the selected cell text
pinColumn Pin column 250 PinColumns Shows a submenu to pin/unpin the column
filterMenu Filter 400 Filter Shows a submenu to control filtering. See Filter submenu.
splitGrid Split 500 Split Shows the "Split grid" sub menu
> splitHorizontally Horizontally 100 Split Split horizontally
> splitVertically Vertically 200 Split Split vertically
> splitBoth Both 300 Split Split both ways
unsplitGrid Split 400 Split Unsplit a previously split grid
>
first level of submenu

Customizing the menu items

The menu items in the Cell menu can be customized, existing items can be changed or removed, and new items can be added. This is handled using the items config of the feature.

Add extra items for all columns:

const grid = new Grid({
    features : {
        cellMenu : {
            items : {
                extraItem : {
                    text   : 'My cell item',
                    icon   : 'fa fa-bus',
                    weight : 200,
                    onItem : () => ...
                }
            }
        }
    }
});

It is also possible to add items using columns config. See examples below.

Add extra items for a single column:

const grid = new Grid({
    columns: [
        {
            field         : 'city',
            text          : 'City',
            cellMenuItems : {
                columnItem : {
                    text   : 'My unique cell item',
                    icon   : 'fa fa-beer',
                    onItem : () => ...
                }
            }
        }
    ]
});

Remove existing item:

const scheduler = new Scheduler({
    features : {
        cellMenu : {
            items : {
                removeRow : false
            }
        }
    }
});

Customize existing item:

const scheduler = new Scheduler({
    features : {
        cellMenu : {
            items : {
                removeRow : {
                    text : 'Throw away',
                    icon : 'fa fa-dumpster'
                }
            }
        }
    }
});

It is also possible to manipulate the default items and add new items in the processing function:

const grid = new Grid({
    features : {
        cellMenu : {
            processItems({items, record}) {
                if (record.cost > 5000) {
                    items.myItem = { text : 'Split cost' };
                }
            }
        }
    }
});

The processItems implementation may be an async function which awaits a result to mutate the items object.

Full information of the menu customization can be found in the "Customizing the Cell menu and the Header menu" guide.

This feature is enabled by default.

Keyboard shortcuts

This feature has the following default keyboard shortcuts:

Keys Action Action description
Space showContextMenuByKey Shows context menu for currently focused cell
Ctrl+Space showContextMenuByKey Shows context menu for currently focused cell

Please note that Ctrl is the equivalent to Command and Alt is the equivalent to Option for Mac users

For more information on how to customize keyboard shortcuts, please see our guide.

See also

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isCellMenu : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of CellMenu class, or subclass thereof.

Functions

Functions are methods available for calling on the class

    Events

    Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

    Event handlers

    Event handlers are callbacks called as a result of certain actions in this class
    id: cellMenu

    Source path

    Grid/feature/CellMenu.js

    Demo

    examples/contextmenu

    Contents