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

Grouped display

The grouped display keeps the grid, with its columns, cells, selection and row actions, and draws a header row before each group of rows that share a value of one column: a status, or the calendar day or week of a date ("Today · 29 Sept", "Week of 21 Sept"). It suits a timeline of runs, a list of tickets by state, an activity log by day: anywhere a module would otherwise build its own "timeline" display.

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

The example above groups Helio's projects by the day each is planned to start, newest first. Collapse a day: its rows hide and its header keeps the count. The footer still describes every row, not only the expanded groups.

Usage

Setting grouped offers the display in the table's display switcher; defaultDisplay opens it first, and a view may open it with display: "grouped":

src/pages/job-runs.ts ts
static runs = TableView(jobRunDataAPI, {
  caption: "Job runs",
  grouped: { groupByField: "startedAt", by: "day", collapsible: true, count: true },
  defaultDisplay: "grouped",
});

static byStatus = TableView(jobRunDataAPI, {
  caption: "Runs by status",
  grouped: { groupByField: "status", order: "items", collapsible: true },
  rowActions: { add: false, duplicate: false, edit: false, delete: false },
});

Options

grouped takes a GroupedOptions:

OptionTypeDefaultPurpose
groupByFieldstringrequiredColumn the rows are grouped on. It must be @Sortable(): the list sorts on it so a group's rows follow each other.
by"value" | "day" | "week""value"One group per value, or per calendar day or week of a DateType column.
order"items" | (string | number | boolean)[]NoneThe order of the groups, with by: "value": "items" follows the items of the column's SelectType (its badge), as the kanban's columns do; a list gives the stored values in the order wanted. Left out, the groups follow the sort on the stored value.
collapsiblebooleanfalseA click on a group header folds its rows.
countbooleanfalseGroup headers show how many rows the group holds.
pinnedbooleanfalseThe rows the table's pinnedRows accepts lead the display, in a group of their own. Registration throws without pinnedRows.
pinnedLabelstring"Pinned"Heading of the pinned group ($: i18n key). Registration throws without pinned: true.

Registration throws for an unknown column, a column that is not @Sortable(), a day or week grouping on a column that is not a DateType, an order on a day or week grouping, order: "items" on a column that is not a single SelectType, and an order list that is empty, longer than 50 values or names a value twice.

Behaviour

  • Headers. A value group is titled with the value as its cell draws it (a select's label, a relation's name); rows without a value form a "No value" group. A day reads "Today", "Yesterday" or the date, a week "Week of …", in the reader's time zone and week start.
  • Sort. The rows are listed sorted on the grouped column, newest first for day and week, ascending for value. a sort the user picked on that column keeps its direction. The sort picker is off while the display is open, but a sort on another column orders the rows of each group. That sort is the one a view opens the display with, or one picked on the grid. So does the hand order of a reorder table. The list route sorts on one field, so that order is applied in the browser, over the page listed.
  • Group order. Without order, a text column's groups come in the alphabetical order of their stored values: a list of orders by status opens on "Cancelled". With order, the list route reads the groups one after the other in that order, so the pages are cut across them and the first page opens on the first group. Rows whose value the order does not list, and rows with no value, come last, in the sort's order. A sort the user picks on the grouped column descending reverses the listed groups. Grouped on another column from the options menu, "items" follows that column's badge, while a list of values, which names the configured column's values, no longer applies. The route asks one count per group listed, plus one, before it reads the page.
  • Paging. The display is paged by rows like the grid, with any pagination mode. A page starting inside a group repeats its header on top.
  • Counts. count reads each listed group's row count from the controller's countBatch route (TableViewRoutes.CountBatch, part of TableViewRoutes.All), over the whole filtered list, not only the page. Each group is counted with filter_<groupByField>, so the column must be filterable: true: the route ignores a filter on any other column, and every header would read the whole total. TableView() warns at registration when the route is missing or the column is not filterable. A header still reads without its count if the request fails.
  • Folding applies to the groups of the current page.
  • Pinned rows. With pinned, the rows pinnedRows accepts are taken out of their value's group and lead the page in one group, headed pinnedLabel, as the grid pins them: within the page the list route answers. A source answering every row has them all on the first page. The pinned group folds like the others. With count, its header shows how many pinned rows the page holds, while the other headers still count every row of their value, the pinned ones included. Without pinned, the grouped display keeps its groups and pins nothing, whatever pinnedRows says.
src/pages/job-runs.ts ts
static byProcedure = TableView(jobRunDataAPI, {
  caption: "Runs by procedure",
  pinnedRows: { field: "status", in: ["failing", "degraded"] },
  grouped: { groupByField: "name", count: true, pinned: true, pinnedLabel: "Needs attention" },
  defaultDisplay: "grouped",
});

There are no aggregates in group headers: put totals in the table's footer.

Note

Day and week counts filter on calendar dates in UTC, while the headers group in the reader's time zone: a row within the time-zone offset of midnight can be counted in the neighbouring day.