Core Features

Advanced Features

Vue Data GridColumn Chooser

Version 36.2.0
Enterprise

The Column Chooser is a dialog that displays the grid's columns, allowing users to show, hide and reorder them. When column definitions contain groups, these are displayed as expandable rows containing their child columns.

Open the Column Chooser by selecting Choose Columns from the Column Menu or by calling api.showColumnChooser(). The same column selection panel is also available docked to the side of the grid as part of the Columns Tool Panel.

AG Grid Column Chooser

Customising the Column Chooser Copy Link

The behaviour and appearance of the Column Chooser can be customised with ColumnChooserParams. Set colDef.columnChooserParams to configure the chooser opened from that column, or set defaultColDef.columnChooserParams to apply the same configuration to every column. When opening the chooser through the Grid API, the same options can instead be passed to api.showColumnChooser(params). These options are unset by default.

ColumnChooserParams extends the shared IColumnSelectionPanelParams interface, so the same column selection options apply to the Columns Tool Panel, where they are set through toolPanelParams instead.

Properties available on the ColumnChooserParams interface.

columnLayoutCopy Link
(ColDef | ColGroupDef)[]
Custom Columns Panel layout
suppressSyncLayoutWithGridCopy Link
boolean
To suppress updating the layout of columns as they are rearranged in the grid.
suppressColumnFilterCopy Link
boolean
To suppress the column search.
suppressColumnSelectAllCopy Link
boolean
To suppress the Select / Unselect All widget.
suppressColumnExpandAllCopy Link
boolean
To suppress the Expand / Collapse All widget.
contractColumnSelectionCopy Link
boolean
By default, column groups start expanded. Pass true to start with groups collapsed.
columnLabelRendererCopy Link
any
Component used to render column and column group labels. The checkbox, drag handle and expand controls remain grid managed.
columnLabelRendererParamsCopy Link
any
Additional parameters passed to the columnLabelRenderer.
columnLabelRendererSelectorCopy Link
ColumnSelectionLabelRendererSelectorFunc
Callback to select which renderer to use for an individual column or column group label.

The following example demonstrates the suppression and contractColumnSelection options above; the column label renderer options and columnLayout are covered in the sections below. Note the following:

  • Launch the Column Chooser by selecting Choose Columns from any column menu.
  • The Column Chooser opened from any column ignores column moves in the grid because suppressSyncLayoutWithGrid=true is set on the default column definition.
  • The Name column's chooser does not show the column search, Select / Unselect All or Expand / Collapse All controls because suppressColumnFilter, suppressColumnSelectAll and suppressColumnExpandAll are all set to true.
  • The Age column's chooser starts with column groups collapsed because contractColumnSelection=true.

Custom Column Labels Copy Link

Use columnLabelRenderer in ColumnChooserParams to replace the text shown for columns and column groups. The checkbox, drag handle and group expand controls remain grid managed. Additional properties can be supplied through columnLabelRendererParams.

Use columnLabelRendererSelector to select different renderers for individual columns or column groups. The selector can also provide renderer-specific params; returning undefined falls back to columnLabelRenderer.

<ag-grid-vue
    :components="components"
    :defaultColDef="defaultColDef"
    /* other grid options ... */>
</ag-grid-vue>

this.components = {
    customColumnLabel: CustomColumnLabel,
};
this.defaultColDef = {
    columnChooserParams: {
        columnLabelRenderer: 'customColumnLabel',
        columnLabelRendererParams: {
            columnIcon: '●',
            columnGroupIcon: '◆',
        },
    },
};

For each label in the Column Chooser, the renderer receives the resolved displayName and either column or columnGroup, depending on the item being rendered. The source is always 'columnChooser'. Setting these options on defaultColDef.columnChooserParams applies them to the chooser regardless of which column it is opened from. They can also be supplied when calling api.showColumnChooser(params).

The Column Chooser does not automatically inherit a renderer configured for the Columns Tool Panel. To use the same presentation in both places, register the component once and reference its name from both configurations. Both ColumnChooserParams and IToolPanelColumnCompParams extend the shared IColumnSelectionPanelParams interface.

Column search and accessibility announcements continue to use displayName, rather than text extracted from the renderer. Column selection rows have a fixed height, so renderer content should remain inline and fit within the configured list item height.

Renderer Parameters Copy Link

Properties available on the IColumnSelectionLabelRendererParams<TData = any, TContext = any> interface.

displayNameCopy Link
string | null
The text value resolved from the column or column group definition.
The column being rendered, or null when rendering a column group.
The column group being rendered, or null when rendering a column.
sourceCopy Link
ColumnSelectionPanelSource
The panel in which the label is rendered.
The grid api.
Application context as set on gridOptions.context.

Custom Column Layout Copy Link

By default, the order of columns in the Column Chooser is derived from the columnDefs supplied in the grid options and is kept in sync when columns are moved in the grid.

A custom layout can instead be provided through colDef.columnChooserParams.columnLayout.

<ag-grid-vue
    :columnDefs="columnDefs"
    /* other grid options ... */>
</ag-grid-vue>

// original column definitions supplied to the grid
this.columnDefs = [
    {
        columnChooserParams: {
            columnLayout: [{
                headerName: 'Group 1', // group doesn't appear in grid
                children: [
                    { field: 'c' }, // custom column order with column "b" omitted
                    { field: 'a' }
                ]
            }]
        }
    },
    { field: 'b' },
    { field: 'c' }
];

Providing columnLayout automatically enables suppressSyncLayoutWithGrid. Reordering columns in the grid therefore does not reorder the custom layout displayed in the Column Chooser.

The following example demonstrates custom Column Chooser layouts. Note the following:

  • Open the Column Chooser for the Name column and note that it uses the order specified by columnLayout.
  • Open the Column Chooser for the Age column and note that it uses the current column order from the grid.
  • Drag the Age column to the left of the Name column in the grid.
  • Open the Column Chooser for the Age column and note that Age now appears before Name.
  • Open the Column Chooser for the Name column and note that its custom layout remains unchanged.

Column Chooser API Copy Link

The Column Chooser can be opened and closed through the Grid API.

showColumnChooserCopy Link
Function
Show the column chooser.
hideColumnChooserCopy Link
Function
Hide the column chooser if visible.

The following example demonstrates opening and closing the Column Chooser through the Grid API.

Legacy Tabbed Column Menu Copy Link

With the Legacy Tabbed Column Menu, a column selection panel is displayed within the columnsMenuTab instead of a separate dialog. It supports the same customisation options through columnChooserParams, but columns cannot be dragged to reorder them or to move them between sections.