Configuring the Context Menu

Summary

  • Developers have full control over the Context Menu including the ability to:
    • reorder Menu Items
    • restructure Menu Items
    • remove Menu Items

The Context Menu can be fully configured at design-time to meet users' requirements.

This is done via the customContextMenu function property in Context Menu Options.

The property is a function that receives in its context all the information about the AG Grid and AdapTable Context Menu items and structure, to facilitate full menu manipulation.

Deep Dive

Configuring the Context Menu using the customContextMenu property

Reordering Menu Items

The default order of the Items in the Context Menu is AG Grid Menu items first, then AdapTable Menu items.

But this can be changed by providing a custom implementation of customContextMenu.

Context Menu: Reordering Menu Items
Fork
  • This example shows how to reorder the Menu Items in the Context Menu
  • When opening the Context Menu in the Name column, the order is: AG Grid Menu Items, Open Settings Panel, other AdapTable Menu Items
  • When opening the Context Menu in all other columns, the order is: Open Settings Panel, AG Grid Menu Items, other AdapTable Menu Items

Expand to see the Menu Options configuration

Try It Out
  • Open the Context Menu for a cell in the Name Column and see how it differs to opening the Context Menu in other Columns

Restructuring Menu Items

The customContextMenu property can also be used restructure the Menu Items.

Hint

This is most typically done to meet particular business requirements

For instance, menus can be grouped or nested differently to the default structure provided by AdapTable.

Context Menu: Restructuring Menu Items
Fork
  • This example shows how to restructure the Menu Items in the Context Menu
  • In each Context Menu, all the AG Grid items have been grouped together into one Menu Item (and placed first)
  • Additionally, some of the AdapTable items have been grouped together in 'Info' and 'Actions' sub menus

Expand to see the Menu Options configuration

Removing Menu Items

The customContextMenu property can also be used to remove some Menu Items from the Context Menu.

Removing Menu Items can be done in 2 ways:

  • Hiding an entire section of the Context Menu (either AdapTable or AG Grid)
  • Hiding some Context Menu Items
Context Menu: Removing Menu Items
Fork
  • This example hides specific Menu items from some Context Menus:
    • Name column displays only the Settings Panel & Layout related items
    • Github Stars displays only the AdapTable items
    • Github Watchers displays only the AG Grid items
    • For all other columns, the default Context Menu items are displayed

Expand to see the Menu Options configuration

Row-Grouped Columns

The ContextMenuObject used in the Context Menu includes an isGroupedNode property.

This can be used to provide specific Column Menu Items for Row-Grouped Columns.

Context Menu: Row Group Columns
Fork
  • This example hides all AG Grid Menu items in Row Grouped Column's Context Menu other than 2: Expand All Row Groups and Collapse All Row Groups

Expand to see the Menu Options configuration