# Configuring the Context Menu

Canonical page: https://www.adaptabletools.com/docs/ui-context-menu-configuring

- 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](https://www.adaptabletools.com/docs/technical-reference-context-menu/index.md).

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.

The [Column Menu](https://www.adaptabletools.com/docs/ui-column-menu-configuring/index.md) uses the same pattern with `customColumnMenu` and `CustomColumnMenuContext`. Item `name`s for context menus are listed on [Context Menu Default Structure](https://www.adaptabletools.com/docs/ui-context-menu-default-structure/index.md).

If you return only AdapTable items from `customContextMenu`, merge AG Grid's **`note`** item from `defaultAgGridMenuStructure` when cell notes are enabled — otherwise add / edit note actions disappear.

### Configuring the Context Menu using the customContextMenu property

The `customContextMenu` property is a function which:
- receives a `CustomContextMenuContext` object
- returns a collection of `CustomContextMenuItem` objects:

```
customContextMenu?: (menuContext: CustomContextMenuContext<TData>) => CustomContextMenuItem[];
```

<b>CustomContextMenuContext</b>

The [`CustomContextMenuContext`](https://www.adaptabletools.com/docs/reference/customcontextmenucontext.md) which **the function receives**, contains 4 collections of default menu items & structures:

| Property | Type | Description |
| --- | --- | --- |
| [defaultAdaptableMenuItems](https://www.adaptabletools.com/docs/reference/customcontextmenucontext.md#defaultadaptablemenuitems) | [`AdaptableSystemContextMenuItem`](https://www.adaptabletools.com/docs/reference/adaptablesystemcontextmenuitem.md)`<`[`AdaptableContextMenuItemName`](https://www.adaptabletools.com/docs/reference/adaptablecontextmenuitemname.md)`>[]` | Flat list of all available AdapTable Menu Items |
| [defaultAdaptableMenuStructure](https://www.adaptabletools.com/docs/reference/customcontextmenucontext.md#defaultadaptablemenustructure) | [`DefaultAdaptableMenuStructure`](https://www.adaptabletools.com/docs/reference/defaultadaptablemenustructure.md) | Default structure of Adaptable Menu Items |
| [defaultAgGridMenuItems](https://www.adaptabletools.com/docs/reference/customcontextmenucontext.md#defaultaggridmenuitems) | [`AgGridMenuItem`](https://www.adaptabletools.com/docs/reference/aggridmenuitem.md)`<`[`AgGridContextMenuItemType`](https://www.adaptabletools.com/docs/reference/aggridcontextmenuitemtype.md)`>[]` | Flat list of all available AG Grid Menu Items |
| [defaultAgGridMenuStructure](https://www.adaptabletools.com/docs/reference/customcontextmenucontext.md#defaultaggridmenustructure) | [`DefaultAgGridMenuStructure`](https://www.adaptabletools.com/docs/reference/defaultaggridmenustructure.md) | Default structure of AG Grid Menu Items |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/customcontextmenucontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

And it extends the [`ContextMenuContext`](https://www.adaptabletools.com/docs/reference/contextmenucontext.md) object which contains a number of useful properties:

| Property | Type | Description |
| --- | --- | --- |
| [adaptableColumn](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#adaptablecolumn) | [`AdaptableColumn`](https://www.adaptabletools.com/docs/reference/adaptablecolumn.md)`<TData>` | Current AdapTable Column |
| [agGridColumn](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#aggridcolumn) | `Column` | Current AG Grid Column |
| [gridCell](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#gridcell) | [`GridCell`](https://www.adaptabletools.com/docs/reference/gridcell.md)`<TData>` | Cell that has been clicked; contains cell value |
| [isGroupedNode](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#isgroupednode) | `boolean` | Whether current AG Grid row node is grouped |
| [isRowGroupColumn](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#isrowgroupcolumn) | `boolean` | Whether current Column is Row Grouped |
| [isSelectedCell](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#isselectedcell) | `boolean` | Whether cell that was clicked is also currently selected |
| [isSelectedRow](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#isselectedrow) | `boolean` | Whether cell that was clicked is in a Row that is currently selected |
| [isSingleSelectedCell](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#issingleselectedcell) | `boolean` | Whether the clicked cell is the only selected cell |
| [isSingleSelectedColumn](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#issingleselectedcolumn) | `boolean` | Whether Column that was clicked is only column with selected cells |
| [primaryKeyValue](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#primarykeyvalue) | `any` | Value of Primary Key column in current row |
| [rowNode](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#rownode) | `IRowNode<TData>` | Current AG Grid row node |
| [selectedCellInfo](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#selectedcellinfo) | [`SelectedCellInfo`](https://www.adaptabletools.com/docs/reference/selectedcellinfo.md)`<TData>` | Currently selected cells in the grid |
| [selectedRowInfo](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#selectedrowinfo) | [`SelectedRowInfo`](https://www.adaptabletools.com/docs/reference/selectedrowinfo.md)`<TData>` | Currently selected rows in the grid |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/contextmenucontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

<b>CustomContextMenuItem</b>

The [`CustomContextMenuItem`](https://www.adaptabletools.com/docs/reference/customcontextmenuitem.md) which **the function returns** is slightly more complicated as it can be formed of many different objects, to enable a rich menu experience:

```
export type CustomContextMenuItem =
  | AgGridMenuItem<AgGridContextMenuItemType>
  | AdaptableSystemMenuItem<AdaptableContextMenuItemName>
  | UserContextMenuItem
  | '-'
  | {
      menuType: 'Group';
      label: string;
      subMenuItems: CustomContextMenuItem[];
      disabled?: boolean;
      icon?: AdaptableIcon;
    };

```

As can be seen it can include 3 types of Menu Items (as well as a separator):
- AG Grid Menu Item 
- AdapTable System Context Menu Item
- User Context Menu Item

<b>AG Grid Menu Item</b>

The [`AG Grid Menu Item`](https://www.adaptabletools.com/docs/reference/aggridmenuitem.md) contains a couple of properties

| Property | Type | Description |
| --- | --- | --- |
| [menuType](https://www.adaptabletools.com/docs/reference/aggridmenuitem.md#menutype) | `'AgGrid'` | Type of Menu - always &#39;AgGrid&#39; |
| [name](https://www.adaptabletools.com/docs/reference/aggridmenuitem.md#name) | `MENU_TYPE` | Name of the Menu Type |

<b>AdapTable System Context Menu Item</b>

The [`AdapTable System Context Menu Item`](https://www.adaptabletools.com/docs/reference/adaptablesystemcontextmenuitem.md) has a single MenuType property...

| Property | Type | Description |
| --- | --- | --- |
| [menuType](https://www.adaptabletools.com/docs/reference/adaptablesystemcontextmenuitem.md#menutype) | `'Adaptable'` | Type of Menu - always &#39;Adaptable&#39; |

...but also extends the more verbose  [`AdapTable Menu Item`](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md) object which contains these properties:

| Property | Type | Description |
| --- | --- | --- |
| [category](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md#category) | [`MenuCategory`](https://www.adaptabletools.com/docs/reference/menucategory.md) | Category of Adaptable Menu Item: Module, General, Group or CustomSettingsPanel |
| [icon](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md#icon) | [`AdaptableIcon`](https://www.adaptabletools.com/docs/reference/adaptableicon.md) | Icon to display in Menu Item |
| [isVisible](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md#isvisible) | `boolean` | Whether menu item is visible |
| [label](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md#label) | `string` | Text that appears in the menu |
| [name](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md#name) | `MENU_TYPE_NAME` | Unique name for the Menu Item |
| [onClick](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md#onclick) | `() => void` | Function to invoke when (custom) menu item is clicked |
| [subItems](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md#subitems) | [`AdaptableMenuItem`](https://www.adaptabletools.com/docs/reference/adaptablemenuitem.md)`[]` | Sub Menu Items to display |

<b>User Context Menu Item</b>

The [`User Context Menu Item`](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md) - used for providing bespoke Menu Items - is defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [disabled](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#disabled) | `boolean` | Whether menu item is disabled |
| [frameworkComponent](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#frameworkcomponent) | [`MenuItemFrameworkComponent`](https://www.adaptabletools.com/docs/reference/menuitemframeworkcomponent.md)`<`[`ContextMenuContext`](https://www.adaptabletools.com/docs/reference/contextmenucontext.md)`>` | Optional Framework Component (React, Angular or Vue) used to render the<br/>content of this menu item.<br/><br/>When supplied, AG Grid renders the component inside the menu row using<br/>its own framework adapter. The component receives AG Grid&#39;s<br/>`CustomMenuItemProps`, with the AdapTable-specific extras<br/>(`adaptableApi`, `menuContext`, plus anything passed via<br/>`menuItemParams`) available as `props.menuItemParams`.<br/><br/>Supported in the React, Vue and Angular variants of AdapTable.<br/><br/>For Vue, supply a factory that returns the Vue Component (NOT a render<br/>call), e.g. `({ adaptableApi }) => MyMenuItem`. AG Grid Vue then<br/>instantiates the component using its own framework adapter and passes<br/>`name`, `icon`, `menuItemParams`, ... as props.<br/><br/>For Angular, supply `{ type: MyMenuItemComponent }` where the component<br/>implements `IMenuItemAngularComp` (with `agInit(params)` to receive<br/>`params.menuItemParams.adaptableApi` and `params.menuItemParams.menuContext`).<br/>The `onSetup` callback on `AngularFrameworkComponent` is NOT honoured<br/>for menu items because AG Grid owns the component lifecycle. |
| [hidden](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#hidden) | `boolean` | Whether menu item is hidden |
| [icon](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#icon) | [`AdaptableIcon`](https://www.adaptabletools.com/docs/reference/adaptableicon.md) | Optional icon to display |
| [label](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#label) | `string` | Text to appear in the Menu Item |
| [menuItemParams](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#menuitemparams) | `Record<string, unknown>` | Extra parameters passed through to the Framework Component (alongside<br/>`adaptableApi` and `menuContext`). |
| [menuType](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#menutype) | `'User'` | Type of Menu - always &#39;User&#39; |
| [onClick](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#onclick) | `(menuContext: `[`ContextMenuContext`](https://www.adaptabletools.com/docs/reference/contextmenucontext.md)`) => void` | Function invoked when the Menu Item is clicked |
| [subMenuItems](https://www.adaptabletools.com/docs/reference/usercontextmenuitem.md#submenuitems) | [`CustomContextMenuItem`](https://www.adaptabletools.com/docs/reference/customcontextmenuitem.md)`[]` | Array of Menu Items, enabling limitless levels of menus |

## 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`.

**Example: Context Menu: Reordering Menu Items**

Reordering items in the AdapTable Context Menu

- 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

```ts
contextMenuOptions: {
  customContextMenu: (context: CustomContextMenuContext) => {
    const {
      defaultAgGridMenuStructure,
      defaultAdaptableMenuStructure,
      adaptableColumn,
    } = context;
    const openSettingsPanelMenuItem = defaultAdaptableMenuStructure.find(
      (item) => item !== '-' && item.name === 'settings-panel-open'
    );
    const otherAdaptableMenuItems = defaultAdaptableMenuStructure.filter(
      (item) => item === '-' || item.name !== 'settings-panel-open'
    );
    if (adaptableColumn.columnId === 'name') {
      return [
        openSettingsPanelMenuItem,
        '-',
        ...defaultAgGridMenuStructure,
        '-',
        ...otherAdaptableMenuItems,
      ];
    }
    return [
      ...defaultAgGridMenuStructure,
      '-',
      openSettingsPanelMenuItem,
      '-',
      ...otherAdaptableMenuItems,
    ];
  },
},
```

- Open the Context Menu for a cell in the `Name` Column and see how it differs to opening the Context Menu in other Columns

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {
  AdaptableOptions,
  CustomContextMenuContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Context Menu - Reordering',
  contextMenuOptions: {
    customContextMenu: (context: CustomContextMenuContext) => {
      const {
        defaultAgGridMenuStructure,
        defaultAdaptableMenuStructure,
        adaptableColumn,
        isRowGroupColumn,
      } = context;

      const openSettingsPanelMenuItem: any = defaultAdaptableMenuStructure.find(
        item => item !== '-' && item.name === 'settings-panel-open'
      );
      const otherAdaptableMenuItems = defaultAdaptableMenuStructure.filter(
        item => item === '-' || item.name !== 'settings-panel-open'
      );

      if (!isRowGroupColumn && adaptableColumn.columnId === 'name') {
        return [
          ...defaultAgGridMenuStructure,
          '-',
          openSettingsPanelMenuItem,
          '-',
          ...otherAdaptableMenuItems,
        ];
      }
      return [
        openSettingsPanelMenuItem,
        '-',
        ...defaultAgGridMenuStructure,
        '-',
        ...otherAdaptableMenuItems,
      ];
    },
  },
  initialState: {
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'github_stars',
            'language',
            'github_watchers',
            'updated_at',
            'created_at',
            'has_wiki',
            'pushed_at',
            'open_issues_count',
            'description',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Restructuring Menu Items

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

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.

**Example: Context Menu: Restructuring Menu Items**

Restructuring Items in AdapTable Context Menu

- 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

```ts
contextMenuOptions: {
  customContextMenu: (context: CustomContextMenuContext) => {
    const {defaultAgGridMenuItems, defaultAdaptableMenuItems} = context;
    const infoItems: AdaptableSystemContextMenuItem<AdaptableContextMenuItemName>[] =
      [];
    const actionsItems: AdaptableSystemContextMenuItem<AdaptableContextMenuItemName>[] =
      [];
    const otherItems: AdaptableSystemContextMenuItem<AdaptableContextMenuItemName>[] =
      [];
    defaultAdaptableMenuItems.forEach(item => {
      if (item.category === 'ColumnInfo' || item.category === 'GridInfo') {
        infoItems.push(item);
      } else if (
        item.label === 'Show System Status' ||
        item.label === 'See Cell Summary'
      ) {
        actionsItems.push(item);
      } else {
        otherItems.push(item);
      }
    });
    return [
      {
        menuType: 'Group',
        label: 'AG Grid Actions',
        subMenuItems: defaultAgGridMenuItems,
      },
      '-',
      {
        menuType: 'Group',
        label: 'Info',
        subMenuItems: infoItems,
      },
      {
        menuType: 'Group',
        label: 'Actions',
        subMenuItems: actionsItems,
      },
      '-',
      ...otherItems,
    ];
  },
},
```

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {
  AdaptableOptions,
  AdaptableSystemContextMenuItem,
  CustomContextMenuContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';
import {AdaptableContextMenuItemName} from '@adaptabletools/adaptable';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Context Menu - Restructuring',
  contextMenuOptions: {
    customContextMenu: (context: CustomContextMenuContext) => {
      const {defaultAgGridMenuItems, defaultAdaptableMenuItems} = context;

      const infoItems: AdaptableSystemContextMenuItem<AdaptableContextMenuItemName>[] =
        [];
      const actionsItems: AdaptableSystemContextMenuItem<AdaptableContextMenuItemName>[] =
        [];
      const otherItems: AdaptableSystemContextMenuItem<AdaptableContextMenuItemName>[] =
        [];
      defaultAdaptableMenuItems.forEach(item => {
        if (item.category === 'ColumnInfo' || item.category === 'GridInfo') {
          infoItems.push(item);
        } else if (
          item.label === 'Show System Status' ||
          item.label === 'See Cell Summary'
        ) {
          actionsItems.push(item);
        } else {
          otherItems.push(item);
        }
      });

      return [
        {
          menuType: 'Group',
          label: 'AG Grid Actions',
          subMenuItems: defaultAgGridMenuItems,
        },
        '-',
        {
          menuType: 'Group',
          label: 'Info',
          subMenuItems: infoItems,
        },
        {
          menuType: 'Group',
          label: 'Actions',
          subMenuItems: actionsItems,
        },
        '-',
        ...otherItems,
      ];
    },
  },
  initialState: {
    Dashboard: {
      Tabs: [{Name: 'Demo', Toolbars: ['SystemStatus']}],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['SystemStatus'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'github_stars',
            'language',
            'github_watchers',
            'updated_at',
            'description',
            'created_at',
            'has_wiki',
            'pushed_at',
            'open_issues_count',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## 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

**Example: Context Menu: Removing Menu Items**

Removing Items in AdapTable Context Menu

- 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

```ts
contextMenuOptions: {
  customContextMenu: (context: CustomContextMenuContext) => {
    const {
      defaultAgGridMenuItems,
      defaultAdaptableMenuItems,
      adaptableColumn,
    } = context;
    if (adaptableColumn.columnId === 'name') {
      return defaultAdaptableMenuItems.filter(
        item => item.category === 'SettingsPanel' || item.category === 'Layout'
      );
    }
    if (adaptableColumn.columnId === 'github_stars') {
      return defaultAdaptableMenuItems;
    }
    if (adaptableColumn.columnId === 'github_watchers') {
      return defaultAgGridMenuItems;
    }
    return [...defaultAgGridMenuItems, '-', ...defaultAdaptableMenuItems];
  },
},
```

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {
  AdaptableOptions,
  CustomContextMenuContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Context Menu - Removing',
  contextMenuOptions: {
    customContextMenu: (context: CustomContextMenuContext) => {
      if (!context.isRowGroupColumn) {
        if (context.adaptableColumn.columnId === 'name') {
          return context.defaultAdaptableMenuItems.filter(
            item =>
              item.category === 'SettingsPanel' || item.category === 'Layout'
          );
        }
        if (context.adaptableColumn.columnId === 'github_stars') {
          return context.defaultAdaptableMenuStructure;
        }
        if (context.adaptableColumn.columnId === 'github_watchers') {
          return context.defaultAgGridMenuStructure;
        }
      }
      return [
        ...context.defaultAgGridMenuStructure,
        '-',
        ...context.defaultAdaptableMenuStructure,
      ];
    },
  },
  initialState: {
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'github_stars',
            'language',
            'github_watchers',
            'updated_at',
            'created_at',
            'has_wiki',
            'pushed_at',
            'open_issues_count',
            'description',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## 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.

**Example: Context Menu: Row Group Columns**

Managing Row Group Items in AdapTable Context Menu

- 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

```ts
contextMenuOptions: {
  customContextMenu: (context: CustomContextMenuContext) => {
    const {defaultAgGridMenuStructure} = context;
    if (context.isRowGroupColumn) {
      const expandAllMenuItem = defaultAgGridMenuStructure.find(
        item => item.menuType === 'AgGrid' && item.name === 'expandAll'
      );
      const contractAllMenuItem = defaultAgGridMenuStructure.find(
        item => item.menuType === 'AgGrid' && item.name === 'contractAll'
      );
      return [
        expandAllMenuItem,
        contractAllMenuItem,
      ] as any;
    } else {
      return [
        ...context.defaultAgGridMenuStructure,
        '-',
        ...context.defaultAdaptableMenuStructure,
      ];
    }
  },
},
```

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {
  AdaptableOptions,
  CustomContextMenuContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Context Menu - Row Groups',
  contextMenuOptions: {
    customContextMenu: (context: CustomContextMenuContext) => {
      if (context.isRowGroupColumn) {
        const openSettingsPanelMenuItem =
          context.defaultAdaptableMenuStructure.find(
            item => item === '-' || item.name !== 'settings-panel-open'
          );
        const showColumnInfoMenuItem =
          context.defaultAdaptableMenuStructure.find(
            item => item === '-' || item.name !== 'column-info-show'
          );
        //   return [
        //     ...context.defaultAgGridMenuStructure,
        //     '-',
        //    ...context.defaultAdaptableMenuStructure,
        //  ];
        // @AF - this doesnt work but not sure why...
        return [openSettingsPanelMenuItem, showColumnInfoMenuItem] as any;
      } else {
        return [
          ...context.defaultAgGridMenuStructure,
          '-',
          ...context.defaultAdaptableMenuStructure,
        ];
      }
    },
  },
  initialState: {
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Group Layout',
      Layouts: [
        {
          Name: 'Group Layout',
          TableColumns: [
            'name',
            'github_stars',
            'github_watchers',
            'updated_at',
            'created_at',
            'has_wiki',
            'pushed_at',
            'open_issues_count',
            'description',
          ],
          RowGroupedColumns: ['language'],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```
