Skip to main content
io.select.table() shows records as a table with a radio or a checkbox in front of each row and returns the rows that were picked. Provided by the @awaitio/select-table package.
A User table with Name, email and Account columns, a filter and paging above it and a radio in front of every row, Aiko Tanaka picked
The table has the same filter, pager and value formatting as io.display.table.

Install

Setup

Register it under the key you want in io, see Input components:
app.ts

Usage

user is the record itself, typed like the records in data. The columns are written as in Display Table: a key, { label, accessorKey } or { label, renderCell }, and renderCell can return a colored label or a link the same way.

Props

Several rows

With maxSelections above 1 every row gets a checkbox, and a … menu next to the pager picks rows in bulk: Select all picks every row that matches the filter, on all pages, and Clear all unpicks them. The menu offers only what would change something: no Select all when every matching row is picked or the rows would go past maxSelections, no Clear all when none is picked.

An empty table

data can be empty, e.g. for an account without devices. The person then sees emptyText instead of the table and continues with nothing picked: minSelections never asks for more rows than the table has, so the handler gets [].

Optional

The field is required. Chain .optional() to let it stay empty; the handler then gets TRow[] | undefined, see Optional fields.

Returns

TRow[]: the picked items of data themselves, the same objects the handler passed in, in the order they were picked: every field, Dates and nested objects included. Only the cells go to the browser; it answers with the positions of the picked rows, the server checks them and hands over the items at those positions.

Built-in validation

The server checks every answer, so a crafted request cannot slip in another row:

Custom validation

Chain .validate() for a check of your own. It runs on the server after the checks above, gets the value the handler would get and returns a message to show under the field, or nothing when the value is fine; see Custom validation.