JavaScript Data GridColumns Tool Panel

javascript logo
Enterprise

The Columns Tool Panel provides controls for managing the grid's columns.

Example

In the example below the Columns Tool Panel can be used to show / hide / reorder columns, group rows and aggregate data and perform pivot operations.

Remember to mark the column definitions with enableRowGroup for grouping, enablePivot for pivoting and enableValue for aggregation, otherwise you won't be able to drag and drop the columns to the desired sections.

Selection Action

Selecting columns means different things depending on whether the grid is in pivot mode or not as follows:

  • Pivot Mode Off: When pivot mode is off, selecting a column toggles the visibility of the column. A selected column is visible and an unselected column is hidden. With allowDragFromColumnsToolPanel=true, you can drag a column from the tool panel onto the grid and it will become visible.
  • Pivot Mode On: When pivot mode is on, selecting a column will trigger the column to be either aggregated, grouped or pivoted depending on what is allowed for that column.

Columns Tool Panel Sections

The Columns Tool Panel is split into different sections as described from the top:

  • Top area
    • Pivot Mode Section: Check the 'Pivot Mode' checkbox to turn the grid into Pivot Mode. Uncheck to take the grid out of pivot mode.
    • Expand / Collapse All: Toggle to expand or collapse all column groups.
  • Columns Section
    • This section displays all columns, grouped by column groups, that are available to be displayed in the grid. By default the order of the columns is kept in sync with the order they are shown in the grid, but this behaviour can be disabled.
    • Select / Unselect All: Toggle to select or unselect all columns in the columns section.
    • Select / Unselect Column (or Group): Each column can be individually selected. The Selection Action depends on pivot mode.
    • Drag Handle: Each column can be dragged either with the mouse or via touch on touch devices. The column can then be dragged to one of the following:
      1. Row Groups Section
      2. Values (Pivot) Section
      3. Column Labels Section
      4. Onto the grid (when gridOptions.allowDragFromColumnsToolPanel=true)
      5. Inside Columns Section to reorder columns (see Suppress Column Reordering)
  • Row Groups Section
  • Values Section
    • Columns here will form the grid's Aggregations. The grid calls this function 'Aggregations', however for the UI we follow the Excel naming convention and call it 'Values'.
  • Column Labels (Pivot) Section
    • Columns here will form the grid's Pivot. The grid calls this function 'Pivot', however for the UI we follow the Excel naming convention and call it 'Column Labels'.

Section Visibility

It is possible to remove items from the tool panel. Items are suppressed by setting one or more of the following toolPanelParams to true whenever you are using the agColumnsToolPanel component properties: