RFC 0074 — Grouped rows and subtotals
Status: implemented (2026-11-29) · Target: 0.65.0 · builds on RFC 0067, RFC 0070 and RFC 0071 · see Decisions
Summary
RFC 0067 gave a table its totals, one line for every row, and left "grouped rows and subtotals" for later. A business list is read in groups more often than not: the invoices by customer, the hours by project, the orders by status, each with its own sum. Today the app sorts by the column and the user adds it up in their head, or exports to a spreadsheet to make a pivot.
This RFC lets a Table group its rows by a column:
<Table
rows={invoices}
bind:query
group="customer"
columns={["number", "customer", "due", { key: "amount", align: "end", total: "sum" }]}
label="Invoices"
/>
group(a column's key, orquery.group, the user's choice): the rows in runs of the same value, each under a header row, "Ada Lovelace · 4 invoices", and a column'stotalfor each group on that header.- The user groups from a column's header (its menu: Group by
Customer, Don't group) when the column is
groupable, and a group is collapsed or expanded by its header (a click, ←/→). - A paged list sends
groupin its query; the command orders by it first and answers each group's count and totals in the page'sgroups, so a group cut by the page still says its own whole.make:resource's commands and Laravel'selyraListanswer it. - Saved views keep the grouping (RFC 0070); print and Report print the groups with their subtotals; the CSV stays the rows.
Motivation
- Subtotals are what a list is read for. "How much does each customer owe" is the question an invoice list answers; a total of everything is the second question.
- A sort is not a group. Sorted by customer, the rows are together, but where one customer ends and what they add up to is the reader's work, and over 25 rows a page it's guesswork.
- The spreadsheet is the workaround. RFC 0066 made the export good enough that users reach for it to group, which is a sign the table should.
- A paged list can't do it alone. Grouping a page in the browser gives a group's sum over the rows on the page; a customer with invoices on two pages has two wrong subtotals. The server has to say it, as it says the totals since RFC 0071.
Current state (0.64, and RFC 0073)
Tablehascolumnswithtotal(RFC 0067): a foot line over every row (rows), the page'stotalsfrom the server (a livepage), or "This page"; and a line for the selected rows.totalsOf(rows, cols)ininternal/totals.jscomputes them.querycarriessearch,sort,direction,page,filters; views (RFC 0070) keepfilters,search,sort,directionandcolumns.Page<T>hastotals: Option<BTreeMap<String, f64>>(RFC 0071).make:resource's index command andelyraListanswer it from the model's allowed totals.- Rows are
<tr>s in one<tbody>; ↑/↓ move between them, Space looks, Enter opens.
Design
group
group is a column's key. The table's own group prop is the app's
choice; query.group, when set, is the user's and wins (it's what a view
keeps, and what a paged command gets). null or "" is not grouped.
The rows are ordered by the group's value first (in the sort's direction
if the sort is the group's column, else ascending), then by the sort. A
group is a run of equal values: equal as plainOf compares them, so a
date groups by the day, and an empty value is its own group, last, named
"(None)".
What's drawn
Each group is a <tbody> with a header row:
▾ Ada Lovelace · 4 invoices 12 400,50
2041 Ada Lovelace 2026-11-05 10 000,00
…
▸ Grace Hopper · 2 invoices 860,00
- The header spans the columns up to the first with a
total; from there, each column with atotalhas the group's in its cell, in the column's format and alignment. The group's name is the value through the column'sformat(what the cells show), its count with the table'swords.groupCount(n)("4 rows"; the app'slabelssay "invoices"). - Collapsed, a group is its header alone. A click on it, or
←/→ on it, folds and unfolds it; Alt+
click folds every group. Folded groups are kept with the widths under
persist, by value. - The grouping column stays where it is, shown, unless the user hides it: hiding it is fine, the header says it.
- The foot's total is unchanged: every row.
Keyboard and ARIA
The table stays a table, not a treegrid: each <tbody> is a row group,
and its header row is a <tr> with a <th scope="rowgroup"> holding a
<button aria-expanded>. ↑/↓ move through the headers and the rows alike;
← on a row goes to its group's header, ←/→
on a header fold and unfold it. Grouping and folding are said in the
table's live region ("Grouped by Customer, 12 groups").
Selection
With select, a group's header has a checkbox for its rows (on the page,
as the table's own "select all" is). Selected rows' totals stay the foot's
second line.
The user's grouping
A column with groupable (or groupable on the table: every column, or a
list of keys) gets Group by {column} in its header's menu (the one
choosable opens, and a right click on the header), and the grouped
column's menu Don't group. The choice writes query.group, so a view
saves it (group in a view, RFC 0070), a route can carry it, and a paged
command gets it.
A paged list
query.group goes to the command with the rest. The command orders by
the group's column first, then its sort, so a group's rows are together
across pages, and answers, in the page:
"groups": { "Ada Lovelace": { "count": 4, "totals": { "amount": 12400.5 } }, … }
for the groups on that page, keyed by the value as text. The table uses
them for the headers: a group cut by the page says its whole ("Ada
Lovelace · 4 invoices", 2 of them here). Without groups in the answer,
the header says the page's own, marked "(this page)", as RFC 0067's foot
does.
Page<T>getsgroups: Option<BTreeMap<String, Group>>,Group { count: u64, totals: Option<BTreeMap<String, f64>> },nullwhen not grouped.make:resource's index command takesgroupamong its allowed sort columns, orders by it first, and answersgroupswith aGROUP BYover the same filtered query, limited to the page's values.elyraListtakes agroupsallowlist ('groups' => ['customer', 'status']) and does the same with Eloquent.
Print, Report and the CSV
On paper, every group is unfolded, with its header and subtotals (RFC
0062). A Report keeps a group's header with its first rows across a
page break. The CSV and Copy table are the rows, as RFC 0066 makes them,
ordered as grouped, without the subtotal lines: a spreadsheet's own
grouping does that, and lines that aren't rows break its sums.
Implementation plan
ui/src/internal/groups.js:groupsOf(rows, col, { sort, direction, cols, number })— runs, names, counts and totals; the order. Tested alone.Table.svelte:groupandgroupable,query.group, a<tbody>per group with its header, folding, keys, selection per group, the header menu's items, the words (en, nb);groupsfrom a page.views.js:groupin a view and inqueryOf/matches.substrate/elyra:Page.groupsandGroup;elyra::db: agroup_totalshelper over a filtered query.make:resource:groupin the index command and its tests; the views passgroupableon the filterable columns.- The Laravel package:
groupsinelyraList, its test, and the CI step's list test. - Docs:
table.md(Grouped rows),models.md,backend.md,resources.md, the skills; the CHANGELOG; the roadmap.
Open questions
- One level of grouping, or nested?
Recommendation: one. Two levels (customer, then month) is a pivot,
which the export serves; one level covers the lists apps have, and
groupcan become a list later without breaking. - Subtotals on the group's header, or a line under each group? Recommendation: the header: it's read first, it's there when the group is folded, and a folded list of headers is the summary the user wanted. A line under each doubles the rows.
- The paged list's groups from the server, in this RFC? Recommendation: yes. Without them a paged list's subtotals are wrong without saying so, which is RFC 0071's reason for server totals; both servers are ours to change.
- Subtotal lines in the CSV?
Recommendation: no: the CSV is rows. A spreadsheet groups and sums
them itself, and extra lines break its
SUM. - Group by a value the table doesn't show (a column the app doesn't list)? Recommendation: no: a group is a column's, so its name has the column's label and format.
As built
internal/groups.js:groupKey,inGroupOrder,runsOf,wholesOfandgroupsOf, plain functions. Text is ordered as the locale reads it, numerically (9before10).- The header's menu is the runtime's context menu, on a right click or
Shift+F10 on a header: Group by {column} for a groupable
column, Don't group while grouped, and Columns… with
choosable. A header that has neither opens the Columns menu, as in 0.63. - A group's name is a column's option label when its filter has
options ("Yes", not "true"), else the value through
format. - Folds are kept under
persistin a key of their own,elyra-ui.table.{persist}.groups, by the column grouped by; a table that isn't grouped reads nothing. While the window prints (beforeprint) and in aReport, every group is unfolded. Query::paginate_grouped(db, page, per_page, column)inelyra::db: the group's order, then the query's, and aCOUNTper group on the page (an empty text counts withNULL). The key is the row's JSON value as text, a whole float without its.0, as JavaScript writes it. Its groups have no totals:make:resource's commands have none; the Laravel package's do.elyraList'sgroupsanswers oneGROUP BYover the page's values, with the controller'stotalsper group; the key is the value as the row's JSON has it (a date cast to Carbon is its ISO string, on both sides).make:resource:groupin{Model}Query(local and--backend), checked againstSORTABLE; the view marks each filtered columngroupable: true; the printedelyraListcall has'groups'.- Checked: against a real Laravel app (a group the page cuts says its count and its sum, 960 over two customers, one on the page), and in the browser smoke test (a header's Group by Active, the group sent, "Yes · 130 rows" over a page of 25, then Don't group).
Decisions
Accepted 2026-11-29, with every recommendation:
- One level of grouping;
groupcan become a list later. - A group's subtotals on its header, there when it's folded.
- A paged list's groups from the server (
Page.groups), inmake:resource's commands andelyraList, in this RFC. - The CSV and Copy table are rows, without subtotal lines.
- A group is a shown column's, with its label and format.
Not in this RFC
- Nested groups, and grouping by an expression (a month of a date).
- Groups as a chart (the subtotals as
@elyra/charts' columns): the app has the rows andgroupsOf. - Drag a column to a group bar, as some data grids do: the header's menu is the one way, and the keys reach it.
Alternatives considered
- Group the page in the browser. Simple, and wrong over a paged list: a group's sum would be the page's, a cut group would read as two.
- A treegrid (
role="treegrid"). The rows aren't a tree, and a treegrid's keys (every cell a stop) are a larger change for screen reader users than a<tbody>per group with a header, which tables have had for decades. - Subtotals as the foot of each
<tbody>. Read last, gone when the group is folded; see question 2.