Class PivotTableModel<T>

The table model of a pivot table – a TableModel (all wrappers take it) whose columns follow the pivot: a group column, one column per column key × value, subtotal and total columns, a grouped header and a total row. Created by PivotFactory.createTableModel.

Pivot again at runtime – other fields, values or rows – with TableApi.setPivotConfig: the same model and the same table get new columns (no new model, so no rebuild in the framework wrappers).

Example

const tableModel = PivotFactory.createTableModel<Sale>({
rows: sales, rowFields: ["region"], columnFields: ["monat"], values: ["umsatz"]
});
tableModel.getPivotBody().getResult().getValue(); // 450
tableModel.getPivotConfig().columnFields; // ["monat"]

Since

1.1.94

Type Parameters

  • T = any

    the row type

Hierarchy

Constructors

Properties

bodyAreaModel: AreaModelIf
columnCount: number = 0
columnDefs: ColumnDefIf[] = []
columnSizes: number[] = []
contentHeightInPx: number = 0
contentWidthInPx: number = 0
defaultRowHeights: DefaultRowHeightsIf = ...
fixedLeftColumnCount: number = 0
fixedRightColumnCount: number = 0
footerAreaModel: AreaModelIf
footerVisible: boolean = true

false: the footer is hidden (height 0), see setFooterVisible.

getSelectionModel: GetT<SelectionModelIf> = ...
headerAreaModel: AreaModelIf
headerVisible: boolean = true

false: the header is hidden (height 0), see setHeaderVisible.

kind: "PivotTableModel" = "PivotTableModel"

Marker for isPivotTableModel (works across copies of the core).

overridingColumnWidth: number = -1
padding: Padding = ...
parentSize: number = 400
rowCheckboxVisible: boolean = false
rowCount: number = 0
xPositions: number[] = []

Methods

  • Retrieves the property key of the table row business object associated with the specified column index. It's only available when columnDefs are specified.

    Parameters

    • columnIndex: number

      The index of the column to retrieve the property from.

    Returns string

    The property associated with the specified column index.

  • Recalculates the height and padding for the body area.

    This method retrieves the area model for the "body" area, and updates the rowCount property with the row count of the model.

    The contentHeightInPx property is then updated with the height of the "body" area.

    The method calls the recalcContentWidthInPx() method to recalculate the content width.

    Finally, the method calls the recalcPadding() method to recalculate the padding.

    Returns void

  • Shows or hides a column. The column keeps its definition, position and width – a hidden column has the width 0 (getColumnWidth), is not rendered, copied or exported; showing it again restores its width.

    Works through ColumnDefIf.isVisible: it is replaced by TrueFn / FalseFn (an own isVisible function of the column is replaced, too). Columns without a column definition can't be hidden. With header groups (AreaModelCellGroups) the column is shown only if neither this method nor a collapsed group hides it – expanding the group does not bring back a column hidden here, and vice versa. Weight widths (new Size(1, "weight")) are shared among the shown columns. Recalculates the content width, the padding (fixed columns) and the x positions. Only changes the model – TableApi.setColumnVisible also repaints the table.

    Parameters

    • column: string | number | ColumnDefIf

      column index (fixed columns included), property or column definition

    • visible: boolean

      false hides the column

    Returns boolean

    false if there is no such column definition

    Example

    tableModel.setColumnVisible?.("category", false);
    
  • Sets the width in pixel of a column (by columnIndex) in a table. The width is also stored in the column's ColumnDef (width = the new px size), so it survives a host resize (the widths are recalculated from the ColumnDefs then).

    Parameters

    • columnIndex: number

      The index of the column.

    • width: number

      The desired width of the column.

    Returns void

  • Pivots again with a changed configuration and/or new rows: new keys, columns, header and totals in this model. Prefer TableApi.setPivotConfig – it also lays the table out again; after this method alone the table must be laid out by you.

    Parameters

    • changes: Partial<PivotConfigIf<T>>

      the changed parts, e.g. { columnFields: ["jahr"] }

    • Optional rows: T[]

      new source rows (default: the current ones)

    Returns void

    Example

    pivotModel.setPivotConfig({ values: [{ value: "umsatz", aggregator: "avg" }] });