When using pivot, you can also use
which is very useful to compute a summary for all records in a pivoted group - the
function specified by
is basically called for every item in the pivoted group, while an optional
function is called at the end of the summary, thus giving you the flexibility to compute things like average values (where you actually need access to the full array of the grouped items).
Although we don't have an explicit property in the dataset for quarter info, it's a derived information which can be computed based on the
As a result, by specifying a
prop, we make quarter columns participate in the pivoting grid with useful information.
In a pivoted grid, the default render value for a column with a group summary reducer is the value computed by
. In addition, like shown in the example below, it can be formatted via the column render function.
In order to be able to display pivot summary columns, the corresponding pivot field needs to be an object with a
function will compute the value to be displayed in the column (and follows the same patterns as the
, which you are already used to).
Beyond that, you can also have a
specified for the pivot item, which should be a column configuration and determines how the corresponding pivot summary column will behave.
If you don't need a summary column for a pivot field, you can simply specify the pivot as a
or an object with
The example above also uses footer
in order to display the sum of all values in the corresponding column.
Since some of the columns (like the pivot summary columns) are generated, we specify
as a function, which has access to the currently rendered
. Based on properties of the column, we know if it's the group column (
column.groupColumn === true
), the pivot grand summary column (
column.pivotGrandSummaryColumn === true
), another pivot summary column (
is an array) or a normal pivoted column, where
is an array of the pivot path for the corresponding column (eg:
). In this case, we use the
passed into the footer render function, in order to display the correct value for the footer cell.