Pivot is an AG Grid Enterprise feature, so you’ll need a license key to use it. See Using AG Grid Enterprise for an example of how to use your license key with Dash AG Grid components.
Pivoting allows you to take a column’s values and turn them into columns. For example, you can pivot on Country
to make columns for Ireland, United Kingdom, USA, etc.
Pivoting only makes sense when mixed with aggregation. If you turn a column into a pivot column, you must have at least one aggregation (value) active for the configuration to make sense. For example, if pivoting by country, you must provide something you are measuring such as ‘gold medals per country’.
Pivot mode is required to be turned on for pivoting to work. When the grid is in pivot mode, the following will happen:
If pivot mode is off, then adding or removing pivot columns will have no effect.
To allow a column to be used as pivot column via the Tool Panel, set enablePivot=true on the required columns. Otherwise you won’t be able to drag and drop the columns to the pivot drop zone from the Tool Panel.
To pivot rows by a particular column, mark the column you want to group with pivot=true. There is no limit on the number of columns that the grid can pivot by. For example, the following will pivot the rows in the grid by country and then sport:
columnDefs = [
{ "field": "country", "pivot": True },
{ "field": "sport", "pivot": True }
]
The example below shows a simple pivot on the Sport column using the Gold, Silver and Bronze columns for values.
Columns Date and Year, although defined as columns, are not displayed in the grid as they have no group, pivot or value associated with them.