Tables

Data tables with expression cells, repeating headers, footers with totals, fixed rows and page-aware row breaks.

The results table of the laboratory example rendered by DocStudio with zebra rows, aligned numbers and a footer total row
The results table of the laboratory example rendered by DocStudio with zebra rows, aligned numbers and a footer total row

A table node turns a JSON array into rows. The inventory report example is a 46 row table that continues onto a second page.

Configuration

{
  "id": "lines",
  "type": "table",
  "source": { "path": "items" },
  "repeatHeader": true,
  "zebra": true,
  "rowBreak": "avoid",
  "emptyState": { "mode": "message", "text": "No lines" },
  "columns": [
    {
      "id": "name",
      "header": "Item",
      "cell": { "path": "name" },
      "width": { "mode": "percent", "value": 50 }
    },
    { "id": "qty", "header": "Qty", "cell": { "path": "qty" }, "align": "end" },
    {
      "id": "total",
      "header": "Total",
      "align": "end",
      "cell": { "fn": "mul", "args": [{ "path": "qty" }, { "path": "price" }] }
    }
  ]
}

Data mapping

source names the array. Each column's cell is an expression evaluated against the current row, so a cell can read a field, compute a value or call a formatter. Column widths are auto, fixed (millimetres) or percent.

Footers and totals

A footer row is evaluated with $rows, the list of data rows:

{
  "cells": [
    { "text": "Total", "span": 2 },
    {
      "expr": { "fn": "sum", "args": [{ "path": "$rows" }], "of": { "path": "amount" } },
      "align": "end"
    }
  ]
}

Fixed rows

rows adds fixed body rows before the data rows, and source is optional. A table with fixed rows only is how the financial statement example is built, with spanning section headings and a calculated operating income.

Pagination

In print and PDF output a long table continues on the next page. repeatHeader repeats the header row and rowBreak: "avoid" keeps each row whole. The designer canvas shows the table on one continuous page.

Formatting

headerStyle styles every header cell, a column can add its own, and a cell or row can carry a style. A cell style replaces its align, so also set textAlign there.

Not supported

Cells cannot span rows, and there is no built-in sorting, grouping or pivoting. Prepare the data before you pass it in. See tables in the docs.

Related documentation