[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationFooter summaries

Footer summaries

Show the row count, figures computed by the server over every listed row, and a legend in a table view's footer.

The footer band of a table view shows how many rows the table lists. footer words that count, adds a hint, figures the server computes over the listed rows (a total, a count of failures), and a legend of a select column's colors.

Every table view lays the band out the same way, left to right: the row count, a rule and the page size picker, then the summaries (each after a ·) and the legend; the hint and the pager close it on the right. On a narrow screen the count and the page size stay together on the first line, and the rest wraps below them.

Table TableView
Connecting to the DMS preview…
Connecting DMS 0.25.8 8 options set

The footer of the example above counts the projects, then sums their peak power and counts those on hold, and closes with the status legend. Open the On hold view: the count and both summaries cover the four matching projects. Compare the paginated table, whose footer covers all 32 projects while it shows ten.

src/pages/subscriptions.ts ts
static subscriptions = TableView(subscriptionDataAPI, {
  caption: "Subscriptions",
  footer: {
    countLabel: "$billing.subscriptions.count", // "{count} subscriptions"
    summary: [
      { label: "MRR", field: "mrr", op: "sum" },
      { label: "Past due", op: "count", where: { field: "status", equals: "past_due" } },
    ],
    legend: "status",
  },
});

Options

TableViewFooterOptions:

OptionTypePurpose
countLabelstringRow count text: an i18n key ($) receiving { count }, pluralized on it. Defaults to "{count} items".
hintstringA hint right of the count ($: i18n key).
summaryTableViewFooterSummary[]Figures after the page size picker (below).
legendstringA SelectType column whose items, with their colors, the footer lists. Registration throws for another column.

A summary, TableViewFooterSummary:

FieldTypePurpose
labelstringShown before the figure ($: i18n key).
op"sum" | "count"Sum a column, or count rows.
fieldstringThe column summed; required by sum.
whereRowActionRuleOnly the rows this rule accepts are summed or counted. The row action rule grammar: equals, notEquals, in, notIn, combined with and, or, not.
formatTableViewSummaryFormatIntl.NumberFormat options: style (decimal, percent, currency), currency, notation (standard, compact), minimumFractionDigits, maximumFractionDigits.

Without format, a sum reads like its column's cells (a price as a price) and a count as a whole number. Registration throws for a sum without field, for a field or a where naming an unknown column, and for a malformed where rule: an and or or operand that is not an array of rules, a not operand that is not a rule, an in or notIn operand that is not an array, a comparison whose field is not a string, a rule that names no operator, a nested rule that is not an object, or rules nested more than 64 levels deep. Only the operator the rule dispatches on is checked (and, or, not first, then the first of equals, notEquals, in, notIn), and only keys the rule owns count.

A where operand is checked when a summary is requested, not at registration: a value that is not plain data (a bigint, a symbol, a function, a Map, a class instance or a cyclic structure) makes the summary request throw Malformed row rule. Strings, numbers, booleans, null, dates, and lists or plain objects of those are accepted.

How the figures are computed

The figures cover every row the table lists after its filters, search and tab, not only the page on screen. The server computes them in the database: where reads the stored fields of a row, and it never leaves the server (the client only knows a summary by an id).

They are served by the controller's summary route, GET <location>/summary?ids=<id>, which computes only the summaries a table view declared, with the caller's list permission. TableViewRoutes.All includes it; a controller listing its routes one by one mounts it itself:

src/data/subscriptions.ts ts
DataController(
  Subscription,
  {
    get: TableViewRoutes.Get,
    list: TableViewRoutes.List,
    countBatch: TableViewRoutes.CountBatch,
    summary: TableViewRoutes.Summary,
  },
  Controller("/api/subscriptions"),
)

A table view declaring summaries over a controller that mounts no GET summary route logs a warning at registration, and its figures do not show.

A TableView.fromSource table takes countLabel, hint and legend, but no summary: there is no data controller to compute it.