Class SpreadsheetTableModel

The table model of a spreadsheet (SpreadsheetFactory): its data columns can be inserted and deleted (TableApi.insertColumns).

Since

1.1.99

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.

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

Width in px of a column without ColumnDef and without columnSizes (like the default of ColumnDef).

Methods

  • Calculates the height of the area identified by the given area identifier – the height of the rows the table draws (since 1.1.107 the same source as the rendering):

    1. getConstantRowHeight() of the area model (> 0): row count × that height – O(1), also for millions of rows,
    2. otherwise the sum of getRowHeight(i) of all rows (variable heights; O(n), like the row layout of the body),
    3. only if the model has no row heights of its own (every getRowHeight(i) is 0): row count × defaultRowHeights[area].

    Before 1.1.107 defaultRowHeights[area] came first: an area model with other heights got a wrong scroll height (a scroll bar without overflow, a wrong thumb). The built-in area models take their row height from defaultRowHeights anyway, so nothing changes for them.

    Parameters

    • areaIdent: AreaIdent

      The identifier of the area.

    Returns number

    • The height of the area in px.

    Example

    // an own body with 20 px rows: 3000 rows are 60,000 px high – also if defaultRowHeights.body is 34
    const height = (tableModel as TableModel).getAreaHeight("body");
  • 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

  • Sets the data columns: A… with the given widths (insert/delete columns keep the widths of the moved columns).

    Parameters

    • count: number

      data columns

    • Optional widths: number[] = []

      width per data column in px (missing: the default width)

    Returns void