Pivot Result Columns

Summary

  • Pivot Result Columns are dynamically created by AG Grid when Pivot Layouts are rendered
  • Each Pivot Result Columns is a unique combination of Pivot Column value and Aggregation Column
  • AdapTable allows users to format, filter, sort and size Pivot Result Columns independently
  • AdapTable allows enables saving of Pivot Result Columns order, and reapplies the order when the Layout next loads

Pivot Result Columns are the columns created dynamically by AG Grid when pivoting occurs.

Each AG Grid created Pivot Result Column is the unique permutation of 2 values:

  • each distinct value in a Pivot Column
  • each Aggregation Column

For instance if you Pivot on a column which has 3 distinct values, and you have 2 Aggregation columns, then 6 Pivot Result Columns will be created.

Note

If there are multiple Pivot Columns, then a Pivot Result Column is created for every unique permutation

Generated Ids

AG Grid will give each Pivot Result Column a unique Id.

Important

These Ids are what AdapTable uses to filter, sort, size and position Pivot Result Columns as seen below

The generated Id is typically made up of 4 elements, each separated by an underscore:

  • the word "pivot"
  • the name of the pivot column
  • the pivot column's value
  • the name of the aggregation value

For example, if you had a Pivot Column of currency (with 2 unique values of 'USD' and 'EUR') and 2 aggregation column of price and amount, the 4 dynamically generated columns would be:

  • pivot_currency_USD_price
  • pivot_currency_EUR_price
  • pivot_currency_USD_amount
  • pivot_currency_EUR_amount

Referencing

AdapTable uses the Ids dynamically generated by AG Grid to reference each Pivot Result Column.

This allows the Pivot Result Columns to be individually referenced in the Layout.

Pivot Result Columns can be uniquely identifed for the purposes of:

  • Column Formatting
  • Filtering
  • Sorting
  • Column Sizing

Find Out More

For more details on each of these together with examples see the pages in this section on:

Ordering

AG Grid decides Pivot Result Column order based on the unique permutations at the time of their creation.

Note

This is non-deterministic because the values in a Pivot Column can change between application loads

By default AdapTable will not save this order, which has 2 consequences:

  • users will see the order decided by AG Grid based on values available when Layout loads
  • any changes made by users are not persisted (and essentially overturned when the Layout next loads)

Where this is not the desired behaviour, AdapTable provides an alternative.

This is done by using the PivotResultColumnsOrder property which is available in each Layout.

The property can be set to one of 3 values:

ValueBehaviour
falseNo changes to Pivot Result Column Order are saved (default value)
trueAny changes to Pivot Result Column Order will be persisted and available on reload
[string]List of Column Ids for initial order (and any changes to that order are persisted)
Pivot Result Columns
Fork
  • This example shows how AdapTable Layouts can be configured at the per-Pivot Result Column Level, by setting some behaviours, including:
    • 3 different Formats for the different Github Stars columns (red, green and blue fonts respectively)
    • The pivot_language_JavaScript_github_stars Column is given its own sort order and a larger size
    • There are 3 different Layouts provided to show the different behaviours for Column Order based on the PivotResultColumnsOrder property:
      • Default Order - set to false so that it shows Pivot Result Columns in the order created by AG Grid, and no changes are persisted
      • Tracked Order - set to true so that it also shows Pivot Result Columns in the order created by AG Grid, but now changes are persisted
      • Configured Order - a default list is provided (of the 2 JavaScript columns first), and subsequent changes are persisted