# Configuring the Column Menu

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

- Developers have full control over the Column Menu including the ability to:
  - reorder Menu Items
  - restructure Menu Items
  - remove Menu Items

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

This is done via the `customColumnMenu` function property in [Column Menu Options](https://www.adaptabletools.com/docs/technical-reference-column-menu/index.md).

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

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

### Configuring the Column Menu using the customColumnMenu property

The `customColumnMenu` property is a function which:
- receives a `CustomColumnMenuContext` object
- returns a collection of `CustomColumnMenuItem` objects:

```ts
customColumnMenu?: (menuContext: CustomColumnMenuContext<TData>) => CustomColumnMenuItem[];
```

<b>CustomColumnMenuContext</b>

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

| Property | Type | Description |
| --- | --- | --- |
| [defaultAdaptableMenuItems](https://www.adaptabletools.com/docs/reference/customcolumnmenucontext.md#defaultadaptablemenuitems) | [`AdaptableSystemColumnMenuItem`](https://www.adaptabletools.com/docs/reference/adaptablesystemcolumnmenuitem.md)`<`[`AdaptableColumnMenuItemName`](https://www.adaptabletools.com/docs/reference/adaptablecolumnmenuitemname.md)`>[]` | Flat list of all available AdapTable Menu Items |
| [defaultAdaptableMenuStructure](https://www.adaptabletools.com/docs/reference/customcolumnmenucontext.md#defaultadaptablemenustructure) | `(`[`AdaptableSystemColumnMenuItem`](https://www.adaptabletools.com/docs/reference/adaptablesystemcolumnmenuitem.md)`<`[`AdaptableColumnMenuItemName`](https://www.adaptabletools.com/docs/reference/adaptablecolumnmenuitemname.md)`> \| `[`MenuSeparator`](https://www.adaptabletools.com/docs/reference/menuseparator.md)`)[]` | Default structure of Adaptable Menu Items |
| [defaultAgGridMenuItems](https://www.adaptabletools.com/docs/reference/customcolumnmenucontext.md#defaultaggridmenuitems) | [`AgGridMenuItem`](https://www.adaptabletools.com/docs/reference/aggridmenuitem.md)`<`[`AgGridColumnMenuItemType`](https://www.adaptabletools.com/docs/reference/aggridcolumnmenuitemtype.md)`>[]` | Flat list of all available AG Grid Menu Items |
| [defaultAgGridMenuStructure](https://www.adaptabletools.com/docs/reference/customcolumnmenucontext.md#defaultaggridmenustructure) | `(`[`AgGridMenuItem`](https://www.adaptabletools.com/docs/reference/aggridmenuitem.md)`<`[`AgGridColumnMenuItemType`](https://www.adaptabletools.com/docs/reference/aggridcolumnmenuitemtype.md)`> \| \{ menuType: 'Group'; label: string; subMenuItems: `[`AgGridMenuItem`](https://www.adaptabletools.com/docs/reference/aggridmenuitem.md)`<`[`AgGridColumnMenuItemType`](https://www.adaptabletools.com/docs/reference/aggridcolumnmenuitemtype.md)`>[]; disabled?: boolean; icon?: `[`AdaptableIcon`](https://www.adaptabletools.com/docs/reference/adaptableicon.md)`; \})[]` | Default structure of AG Grid Menu Items |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/customcolumnmenucontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

And it extends the [`ColumnMenuContext`](https://www.adaptabletools.com/docs/reference/columnmenucontext.md) object which contains a few useful properties:

| Property | Type | Description |
| --- | --- | --- |
| [adaptableColumn](https://www.adaptabletools.com/docs/reference/columnmenucontext.md#adaptablecolumn) | [`AdaptableColumn`](https://www.adaptabletools.com/docs/reference/adaptablecolumn.md)`<TData>` | Current AdapTable Column |
| [agGridColumn](https://www.adaptabletools.com/docs/reference/columnmenucontext.md#aggridcolumn) | `Column` | Current AG Grid Column |
| [isRowGroupColumn](https://www.adaptabletools.com/docs/reference/columnmenucontext.md#isrowgroupcolumn) | `boolean` | Whether current Column is Row Group |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/columnmenucontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

<b>CustomColumnMenuItem</b>

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

```ts
export type CustomColumnMenuItem =
  | AgGridMenuItem<AgGridColumnMenuItemType>
  | AdaptableSystemColumnMenuItem<AdaptableColumnMenuItemName>
  | UserColumnMenuItem
  | '-'
  | {
      menuType: 'Group';
      label: string;
      subMenuItems: CustomColumnMenuItem[];
      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 Column Menu Item
- User Column 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 Column Menu Item</b>

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

| Property | Type | Description |
| --- | --- | --- |
| [menuType](https://www.adaptabletools.com/docs/reference/adaptablesystemcolumnmenuitem.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 Column Menu Item</b>

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

| Property | Type | Description |
| --- | --- | --- |
| [disabled](https://www.adaptabletools.com/docs/reference/usercolumnmenuitem.md#disabled) | `boolean` | Whether menu item is disabled |
| [frameworkComponent](https://www.adaptabletools.com/docs/reference/usercolumnmenuitem.md#frameworkcomponent) | [`MenuItemFrameworkComponent`](https://www.adaptabletools.com/docs/reference/menuitemframeworkcomponent.md)`<`[`ColumnMenuContext`](https://www.adaptabletools.com/docs/reference/columnmenucontext.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/usercolumnmenuitem.md#hidden) | `boolean` | Whether menu item is hidden |
| [icon](https://www.adaptabletools.com/docs/reference/usercolumnmenuitem.md#icon) | [`AdaptableIcon`](https://www.adaptabletools.com/docs/reference/adaptableicon.md) | Optional icon to display |
| [label](https://www.adaptabletools.com/docs/reference/usercolumnmenuitem.md#label) | `string` | Text to appear in the Menu Item |
| [menuItemParams](https://www.adaptabletools.com/docs/reference/usercolumnmenuitem.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/usercolumnmenuitem.md#menutype) | `'User'` | Type of Menu - always &#39;User&#39; |
| [onClick](https://www.adaptabletools.com/docs/reference/usercolumnmenuitem.md#onclick) | `(menuContext: `[`ColumnMenuContext`](https://www.adaptabletools.com/docs/reference/columnmenucontext.md)`) => void` | Function invoked when the Menu Item is clicked |
| [subMenuItems](https://www.adaptabletools.com/docs/reference/usercolumnmenuitem.md#submenuitems) | [`CustomColumnMenuItem`](https://www.adaptabletools.com/docs/reference/customcolumnmenuitem.md)`[]` | Array of Menu Items, enabling limitless levels of menus |

## Reordering Menu Items

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

But the menu can be **re-ordered** by providing a custom implementation of `customColumnMenu`.

**Example: Column Menu: Reordering Menu Items**

Reordering items in the AdapTable Column Menu

- This example shows how to **reorder** the Menu Items in the Column Menu
 - When opening the Column Menu in the `Name` column, the order is: AG Grid Menu Items, `Open Settings Panel`, other AdapTable Menu Items
 - When opening the Column 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
columnMenuOptions: {
  customColumnMenu: (context: CustomColumnMenuContext) => {
    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 Column Menu for a cell in the `Name` Column and see how it differs to opening the Column 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,
  CustomColumnMenuContext,
  CustomContextMenuContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Column Menu - Reordering',
  columnMenuOptions: {
    customColumnMenu: (context: CustomColumnMenuContext) => {
      const {
        defaultAgGridMenuStructure,
        defaultAdaptableMenuStructure,
        adaptableColumn,
      } = 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 (!context.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 `customColumnMenu` property can also be used **restructure** the Menu Items in line with user requirements.

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

**Example: Column Menu: Restructuring Menu Items**

Restructuring Items in AdapTable Column Menu

- This example shows how to restructure the Menu Items in the Column Menu
- In each Column 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
columnMenuOptions: {
  customColumnMenu: (context: CustomColumnMenuContext) => {
    const {defaultAgGridMenuItems, defaultAdaptableMenuItems} = context;
    const infoItems: AdaptableSystemColumnMenuItem<AdaptableColumnMenuItemName>[] =
      [];
    const actionsItems: AdaptableSystemColumnMenuItem<AdaptableColumnMenuItemName>[] =
      [];
    const otherItems: AdaptableSystemColumnMenuItem<AdaptableColumnMenuItemName>[] =
      [];
    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 {
  AdaptableColumnMenuItemName,
  AdaptableOptions,
  AdaptableSystemColumnMenuItem,
  CustomColumnMenuContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Column Menu - Restructuring',
  columnMenuOptions: {
    customColumnMenu: (context: CustomColumnMenuContext) => {
      const {defaultAgGridMenuItems, defaultAdaptableMenuItems} = context;

      const infoItems: AdaptableSystemColumnMenuItem<AdaptableColumnMenuItemName>[] =
        [];
      const actionsItems: AdaptableSystemColumnMenuItem<AdaptableColumnMenuItemName>[] =
        [];
      const otherItems: AdaptableSystemColumnMenuItem<AdaptableColumnMenuItemName>[] =
        [];
      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 `customColumnMenu` property can also be used to **remove** some Menu Items from the Column Menu.

Removing Menu Items can be done in 2 ways:

- Hiding an entire section of the Column Menu (either AdapTable or AG Grid)
- Hiding particular Column Menu Items

**Example: Column Menu: Removing Menu Items**

Removing Items in AdapTable Column Menu

- This example hides specific Menu items from some Column Menus:
  - `Name` column displays only the `Settings Panel` & (the 5)`Layout` related items
  - `Github Stars` displays only the AdapTable items
  - `Github Watchers` displays only the AG Grid items
  - For all other columns, the default Column Menu items are displayed
### Expand to see the Menu Options configuration

```ts
columnMenuOptions: {
  customColumnMenu: (context: CustomColumnMenuContext) => {
    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,
    ];
  },
},
```

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,
  CustomColumnMenuContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Column Menu - Removing',
  columnMenuOptions: {
    customColumnMenu: (context: CustomColumnMenuContext) => {
      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 `ColumnMenuObject` used in the Column Menu includes an `isRowGroupColumn` property.

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

**Example: Column Menu: Row Group Columns**

Managing Row Group Items in AdapTable Column Menu

- This example hides all AG Grid Menu items in Row Grouped Column's Column Menu other than 3: `Un-Group All`, `Expand All Row Groups` & `Collapse All Row Groups` 
### Expand to see the Menu Options configuration

```ts
columnMenuOptions: {
  customColumnMenu: (context: CustomColumnMenuContext) => {
    const {defaultAgGridMenuStructure} = context;
    if (context.isRowGroupColumn) {
      const rowUngroupMenuItem = defaultAgGridMenuStructure.find(
        item => item.menuType === 'AgGrid' && item.name === 'rowUnGroup'
      );
      const expandAllMenuItem = defaultAgGridMenuStructure.find(
        item => item.menuType === 'AgGrid' && item.name === 'expandAll'
      );
      const contractAllMenuItem = defaultAgGridMenuStructure.find(
        item => item.menuType === 'AgGrid' && item.name === 'contractAll'
      );
      return [
        rowUngroupMenuItem,
        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,
  CustomColumnMenuContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Column Menu - Row Groups',
  columnMenuOptions: {
    customColumnMenu: (context: CustomColumnMenuContext) => {
      const {defaultAgGridMenuStructure} = context;
      if (context.isRowGroupColumn) {
        const rowUngroupMenuItem = defaultAgGridMenuStructure.find(
          item => item.menuType === 'AgGrid' && item.name === 'rowUnGroup'
        );
        const expandAllMenuItem = defaultAgGridMenuStructure.find(
          item => item.menuType === 'AgGrid' && item.name === 'expandAll'
        );
        const contractAllMenuItem = defaultAgGridMenuStructure.find(
          item => item.menuType === 'AgGrid' && item.name === 'contractAll'
        );
        return [
          rowUngroupMenuItem,
          expandAllMenuItem,
          contractAllMenuItem,
        ] 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,
        },
      ],
    },
  },
};
```
