Skip to content

Summary row cells ​

A row of summary.rows shows one aggregate per column by default. Use cells when you want to define the cells of one row yourself. Everything is optional, and without it nothing changes. A bad value throws invalid-option before any state changes.

KeyWhat it does
summary.rows[].cellsThe cells of that row; replaces the aggregate map when present
cells[].columnThe column whose position the cell occupies
cells[].fromThe column the value is read from; default column
cells[].aggregateThe aggregate of this cell; default the aggregate of the from column
cells[].spanNumber of columns to cover (1 or more); default 1
cells[].classOne CSS class name (letters, digits, -, _)
cells[].textA string or function drawn in place of the value
grouping.summaryAlign'label' (default) or 'lastGroup': put the subtotal label in the deepest group column
grouping.mergeSummaryThe subtotal label covers the empty cells after it
summary.includeFilteredOutWith true, rows removed by a filter count in the totals; default false
ts
summary: {
  rows: [
    {
      id: 'total',
      cells: [
        { column: 'name', text: 'Total', span: 2 },
        { column: 'amount', aggregate: 'sum', class: 'total-cell' },
        { column: 'bonus', from: 'amount', aggregate: 'max' },
      ],
    },
  ],
}

A cell value is drawn at column and formatted with that column's aggregateFormat. With text, the string is drawn instead of the value. A function receives an AggregateContext and can read the rows of this total through ctx.rows; the array is built only when read, so unused it costs nothing.

Merging sideways ​

span covers that many columns from column to the right. Covered cells are hidden and the merged cell gets aria-colspan. The span is cut at the border between the pinned zone and the middle zone, so a cell never straddles two zones. While columns are virtualized horizontally (a table with 24 or more columns), cells are not merged and each is drawn alone. Export writes the aggregate of a cell into its column and leaves covered columns empty; cells that only have text are not exported.

Subtotal label ​

grouping.summaryAlign: 'lastGroup' puts the label of a subtotal row ("… subtotal") in the column of the deepest group field instead of the first column. mergeSummary: true lets the label cell cover the empty cells on its right up to the first aggregate. Both can be combined.

Filtered-out rows ​

By default only rows that pass the filter are summed. summary.includeFilteredOut: true computes the grand total over all rows. Group rows and subtotals still sum the visible rows only, because filtered-out rows are not part of the group structure.

Clicks on summary cells ​

summaryCellClicked and summaryCellDoubleClicked receive { rowId, columnId, scope, key, event }. scope is 'grid' for the grand total and 'group' for a subtotal, and key is the group key of a subtotal (null for the grand total). rowId is the summary.rows[].id, or an empty string for a row without one. The click does not select or focus a row and fires no rowClicked or cellClicked.

While either event has a listener, summary and subtotal cells show a pointer cursor, are reachable with Tab (tabindex="0") and Enter or Space fires the same click event. Without listeners nothing changes.