New to Kendo UI for Angular? Start a free 30-day trial

Angular Data Grid Column Menu

The Grid enables you to show a menu with quick actions for its columns.

The column menu provides a convenient way to apply data processing features to the specified columns. The user can sort and filter the grid data, toggle the locked and sticky state of the columns, or change their visibility. You can customize the order of the menu items and create custom controls as necessary.

To display the column menu on each column, set the columnMenu option of the Grid. The property accepts both boolean and ColumnMenuSettings parameters. The default value of the columnMenu option is false.

The following example demonstrates a basic column menu in action.

Example
View Source
Change Theme:

Configuring the Column Menu

To specify which items to appear in the column menu, pass a ColumnMenuSettings parameter object to the columnMenu option.

The available predefined column menu items are:

  • Sort itemDisplays Sort Ascending and Sort Descending buttons, which apply the corresponding sorting to the current column. If the Grid is sortable, this option defaults to true for model-bound columns.
  • Filter itemDisplays a Filter button and an expandable filter menu. If the Grid is filterable, this option defaults to true for model-bound columns.
  • Lock and unlock itemsDetermines if the users can lock and unlock the column through the column menu. Defaults to false.
  • Stick and unstick itemsDetermines if the users can enable and disable sticky columns through the column menu. Defaults to false.
  • Set-column-position itemDisplays the Lock/Unlock and Stick/Unstick buttons under an expandable Set Column Position item instead on a root level. Defaults to false.
  • Column Chooser itemDisplays a Columns button and an expandable checkbox-style menu with all columns. It enables users to quickly show or hide the Grid columns. Defaults to true.

Sort Item

The sort item of the column menu is displayed by default if the following conditions are met:

  • The sortable functionality of the Grid is enabled.
  • The current column is bound to a field from the Grid model.

To add the sort item without enabling sorting, manually set the sort option of the ColumnMenuSettings to true. To hide the sort item for individual columns, set the sortable option of the column to false.

Example
View Source
Change Theme:

Filter Item

The filter item of the column menu is displayed by default if the following conditions are met:

  • The filterable functionality of the Grid is enabled.
  • The current column is bound to a field from the Grid model.

To add the filter item without enabling filtering, set the filter option of the ColumnMenuSettings to true. To hide the filter item for individual columns, set the filterable option of the column to false.

Example
View Source
Change Theme:

Lock and Unlock Items

The lock and unlock items of the column menu are not displayed by default. To add them, set the lock option of the ColumnMenuSettings to true. To hide the lock and unlock items for individual columns, set the lockable option of the corresponding column to false.

The prerequisites and limitations of the locked columns apply to the lock item too.

The following example demonstrates how to lock and unlock columns from the column menu.

Example
View Source
Change Theme:

Stick and Unstick Items

The stick and unstick items of the column menu are not displayed by default. To add them, set the stick option of the ColumnMenuSettings to true. To hide the stick and unstick items for individual columns, set the stickable option of the corresponding column to false.

The prerequisites and limitations of the sticky columns apply to the stick item too.

The following example demonstrates how to allow users to set the sticky state of Grid columns through the column menu.

Example
View Source
Change Theme:

Set-Column-Position Item

By default, the lock and stick items are displayed on the root level of the column menu. To nest them in an expandable Set Column Position sub-menu, set the setColumnPosition of the ColumnMenuSettingsto true.

The prerequisites and limitations of the sticky and locked columns apply to the set-column-position item too.

The following example demonstrates how to add the set-column-position item to the column menu.

Example
View Source
Change Theme:

Column Chooser Item

The column chooser item allows you to dynamically show and hide columns through a dedicated sub-menu with checkboxes. The column menu displays a column chooser item by default. To hide it, set the columnChooser option of the ColumnMenuSettings to false.

The following example demonstrates how to hide the column chooser item.

Example
View Source
Change Theme:

To exclude a column from the column chooser checkbox list, set the includeInChooser property of the respective column to false.

Example
View Source
Change Theme:

Expandable Menu Items

By default, the column chooser, filter, and set-column-position column menu items are initially collapsed. To change this behavior and make them initially expanded, set the [expanded]slug:api_grid_expandablecolumnmenuitem property of the [ExpandableColumnMenuItem]({% slug api_grid_expandablecolumnmenuitem %}] object to true.

Example
View Source
Change Theme:

Customizing the Content

You can customize the content of the column menu through templates. This approach allows you to specify a column menu template for:

  • All ColumnsNest an <ng-template> tag with the kendoGridColumnMenuTemplate directive inside the kendo-grid component.
  • Specific ColumnNest the template inside the column component tag, for example, inside kendo-grid-column.

Before using the predefined column menu items inside the template, set ColumnMenuService that is passed by the template to the service input of the column menu item.

To include the predefined column menu items in the template, add the following components:

The following example demonstrates how to define a custom column menu template.

Example
View Source
Change Theme:

Customizing the Position

By default, the Column Menu is rendered as the last item in the header cell. To change the position of the menu icon in the header:

  1. Disable the built-in column menu by setting columnMenu on the respective column to false.
  2. Nest an <ng-template> tag inside the column and apply a kendoGridHeaderTemplate directive to it.
  3. Place a ColumnMenu component anywhere in the header template by nesting a <kendo-grid-column-menu> tag inside.
  4. Bind the column property of the ColumnMenu component to the column field that is passed by the template.
  5. Optionally, bind the sort and filter properties of the ColumnMenu component to the respective Grid state.

When used as a standalone component, the ColumnMenu ignores the sortable and filterable settings of the Grid. You must configure the respective column menu items through the component properties instead.

The following example demonstrates the described approach for changing the column menu position inside the cell header template.

Example
View Source
Change Theme:

Hiding the Column Menu per Column

By default, the column menu appears for all columns. To disable the column menu for specific columns, use the columnMenu option of the respective column and set it to false.

Example
View Source
Change Theme:

Using Standalone Column Chooser

You can use the column chooser item outside the column menu.

To allow the user to show and hide the columns without including the column chooser item in the column menu, use the ColumnChooser component separately by nesting a <kendo-grid-column-chooser> tag inside the Grid toolbar.

Example
View Source
Change Theme: