Static createCreates the table model of a pivot table (see the class description).
rows, row fields, column fields, values, options
the table model – a TableModelIf
// case 3: the average – Jan total is 230 / 3 = 76.67, not the mean of the region averages (77.5)
const tableModel = PivotFactory.createTableModel<Sale>({
rows: sales, rowFields: ["region"], columnFields: ["monat"],
values: [{ value: "umsatz", aggregator: "avg" }]
});
Creates pivot tables: rows grouped by row fields (a hierarchy with subtotals), the values of column fields as columns (several fields = a multi-row header), aggregated values in the cells, total column and total row. MIT-licensed, no dependencies – at ag-Grid this is an Enterprise feature.
The configuration has the form of a row grouping (RowGroupFactory): fields are property paths, functions (e.g. the quarter of a date) or RowGroupFieldIf with label, format and order; values use the aggregators of Aggregators (
sum,avg,count…) or your own AggregatorIf. Subtotals and totals are merged from aggregation states – an average is always the average of the rows.Filter with
externalFilterFunction(it gets your source objects, before the aggregation), sort by clicking a value column, export withdownloadExcel(), and pivot again at runtime with TableApi.setPivotConfig.Example
Example
See
Live demo: pivot tables · Training: Pivot tables
Since
1.1.94