We just wrapped up AG Studio Launch Week See what we shipped




Core Features

Advanced Features

JavaScript Data GridColumns Tool Panel - Configuration

Version 36.3.0
Enterprise

Choose which sections and columns the Columns Tool Panel shows, arrange its list of columns, and make grouping, aggregation and pivoting read only.

The example above shows the Columns Tool Panel with its default configuration, sideBar: 'columns'. Note the following:

  • Columns can only be dragged into the Row Groups, Values and Column Labels sections when their column definition allows it, using enableRowGroup, enableValue and enablePivot respectively.
  • The athlete, age, country, year, date and sport columns set enableRowGroup and enablePivot, so they can be dragged to the Row Groups section, and to the Column Labels section once Pivot Mode is on.
  • The medal columns set enableValue, so they can be dragged to the Values section.

Section Visibility Copy Link

To remove a section from the Columns Tool Panel, set suppressPivotMode, suppressRowGroups, suppressValues or suppressPivots in toolPanelParams. To remove a control from the top area, set suppressColumnExpandAll, suppressColumnSelectAll or suppressColumnFilter.

Section Visibility API Copy Link

Show or hide the Pivot Mode, Row Groups, Values and Column Labels sections after the grid is created by calling setPivotModeSectionVisible(), setRowGroupsSectionVisible(), setValuesSectionVisible() or setPivotSectionVisible():

// get the Columns Tool Panel instance
const columnsToolPanel = api.getToolPanelInstance('columns');

// hides the Row Groups section
columnsToolPanel.setRowGroupsSectionVisible(false);

// shows the Column Labels section
columnsToolPanel.setPivotSectionVisible(true);

The example below hides all of these sections and controls with the parameters above. Note the following:

  • The Pivot Mode, Row Groups, Values and Column Labels checkboxes show and hide each section using the api methods.
  • The Expand / Collapse All, Select / Unselect All and Search controls stay hidden, as they can only be set through toolPanelParams.
  • The date column is hidden from the tool panel; see Hiding Columns.

Hiding Columns Copy Link

To remove a column from the tool panel, set suppressColumnsToolPanel on its column definition. This is useful for a column that works in the background, such as one the grid groups by, that users should not see.

Suppress Column Reordering Copy Link

By default, reordering columns in the grid also reorders them in the Columns section. Set suppressSyncLayoutWithGrid to keep the tool panel order fixed.

Users can also reorder columns by dragging them within the Columns section. Set suppressColumnMove to prevent this. suppressSyncLayoutWithGrid also prevents it, so suppressColumnMove is only needed on its own when the tool panel should still follow the grid order.

const gridOptions = {
    sideBar: {
        toolPanels: [
            {
                id: 'columns',
                labelDefault: 'Columns',
                labelKey: 'columns',
                iconKey: 'columns',
                toolPanel: 'agColumnsToolPanel',
                toolPanelParams: {
                    // tool panel columns won't move when columns are reordered in the grid
                    suppressSyncLayoutWithGrid: true,
                    // prevents columns being reordered from the Columns Tool Panel
                    suppressColumnMove: true,
                },
            },
        ],
        defaultToolPanel: 'columns',
    },

    // other grid options ...
}

The example below enables both properties. Note the following:

  • Moving columns in the grid doesn't reorder columns in the Columns Tool Panel, as suppressSyncLayoutWithGrid=true.
  • Columns can't be reordered from the Columns Tool Panel, as both properties are enabled.

Custom Column Layout Copy Link

By default, the Columns section follows the order of columnDefs and stays in sync as columns move in the grid. To define a different layout, pass Column Definitions to setColumnLayout() on the Columns Tool Panel instance.

Given these column definitions supplied to the grid:

const gridOptions = {
    columnDefs: [
        { field: 'a' },
        { field: 'b' },
        { field: 'c' }
    ],

    // other grid options ...
}

The following layout adds a group, reorders the columns and omits column b:

const columnsToolPanel = api.getToolPanelInstance('columns');
columnsToolPanel.setColumnLayout([
    {
        headerName: 'Group 1', // group doesn't appear in grid
        children: [
            { field: 'c' }, // custom column order with column "b" omitted
            { field: 'a' }
        ]
    }
]);

The layout can contain column groups that don't exist in the grid, and can omit or reorder columns, but every column it references must already exist in the grid.

When providing a custom layout, enable suppressSyncLayoutWithGrid so that moving columns in the grid does not replace it (see Suppress Column Reordering).

The example below shows two custom layouts for the Columns Tool Panel. Note the following:

  • When the grid is initialised, the Columns Tool Panel layout matches gridOptions.columnDefs.
  • Custom Sort Layout calls setColumnLayout(colDefs) with the columns in ascending order.
  • Custom Group Layout calls setColumnLayout(colDefs) with column groups that don't appear in the grid.
  • Moving columns in the grid doesn't affect the custom layouts, as suppressSyncLayoutWithGrid is enabled.
  • Moving columns within the Columns Tool Panel is disabled, as suppressSyncLayoutWithGrid and suppressColumnMove are enabled.

Read Only Functions Copy Link

Set the grid option functionsReadOnly=true to prevent users changing grouping, pivoting or aggregation through the UI. The Row Groups, Values and Column Labels sections stay visible, so users can see which columns are in use but cannot change them.

The example below starts with functionsReadOnly=true. Note the following:

  • The grid is in pivot mode, grouped by country and sport, pivoted by year, with silver and bronze aggregated.
  • Columns cannot be dragged into or removed from the Row Groups, Values and Column Labels sections.
  • Untick Functions Read Only to allow changes again.

Parameters Copy Link

The Columns section and the Column Chooser use the same column selection panel. Their shared options are defined by IColumnSelectionPanelParams, while IToolPanelColumnCompParams adds options specific to the Columns Tool Panel. See Providing Parameters to Tool Panels for how to pass these to the tool panel.

IColumnSelectionPanelParams Copy Link

Properties available on the IColumnSelectionPanelParams interface.

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 result can also provide renderer-specific params. Return undefined to use columnLabelRenderer.

IToolPanelColumnCompParams Copy Link

Properties available on the IToolPanelColumnCompParams interface.

suppressColumnMoveCopy Link
boolean
Suppress Column Move
suppressRowGroupsCopy Link
boolean
Suppress Row Groups section
suppressValuesCopy Link
boolean
Suppress Values section
suppressPivotsCopy Link
boolean
Suppress Column Labels (Pivot) section
suppressPivotModeCopy Link
boolean
Suppress Pivot Mode selection
buttonsCopy Link
ColumnToolPanelAction[]
Buttons to display at the bottom of the Columns Tool Panel, in the order they should be displayed in.
  • 'apply': Changes are deferred until the Apply button is clicked.
  • 'cancel': Discards any deferred changes. Only has an effect when 'apply' is also included.
  • 'reset': Immediately resets the columns to the state defined in the current column definitions, discarding any pending changes.
  • Only the 'apply' button enables deferred changes.

    API Copy Link

    Columns Tool Panel Instance Copy Link

    Get the Columns Tool Panel instance from the grid API using its tool panel id, which is 'columns' by default:

    const columnsToolPanel = api.getToolPanelInstance('columns');
    setColumnLayoutCopy Link
    Function
    Sets a custom layout of columns and column groups for the Columns section. Every referenced column must already exist in the grid.
    setPivotModeSectionVisibleCopy Link
    Function
    Shows or hides the Pivot Mode section.
    setRowGroupsSectionVisibleCopy Link
    Function
    Shows or hides the Row Groups section.
    setValuesSectionVisibleCopy Link
    Function
    Shows or hides the Values section.
    setPivotSectionVisibleCopy Link
    Function
    Shows or hides the Column Labels (pivot) section.