Skip to content

DataTable ​

Table + sort/search/select/paginate

Rows people sort, search, page through and pick from — an admin list, an order history. For a small table that just shows data, use Table; for cards instead of rows, DataView.

Everything runs in the browser by default — hand it the full array and it sorts, filters and slices. For large sets switch to server mode below and the table becomes a thin view over one page at a time. When rows nest, TreeTable.

Basic
Episodes
Status
1第1話 プロローグ2017-04-011,200aired
2第2話 運命の出会い2017-04-021,658aired
3第3話 フラグの立たない2017-04-031,729aired
4第4話 冴えない彼女2017-04-041,382aired
5第5話 同人誌2017-04-05970aired
23 rows
Server mode
Episodes (server-paged)
No rows.
0 rows
0 rows on the “server”, 0 in the DOM

Server mode — pass server and total; the rows you give are the current page, and every sort / search / page / page-size change emits state for you to fetch with. Nothing is sorted or sliced on the client.

  • Client mode sorts, filters and pages rows itself. With server, rows is one page: listen to @state (sort, query, page, page size) and fetch; set total and loading while you do — the table is marked busy and dims.
  • Mark one column header: true: its cells become row headers, and row checkboxes are named after them ("Select Megumi").
  • @rowClick is for pointer convenience only. Put a link or button in a cell for anything keyboard users must reach.
  • The row count is a status, so a search or page change is announced.

Usage ​

ts
import { BlessDataTable } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
columns*BlessDataColumn<T>[]—
rows*T[]—
rowKey*keyof T & string—
pageSizenumber10
pageSizesnumber[][10, 25, 50]
selectableboolean—
searchableboolean—
searchKeys(keyof T & string)[]—
searchPlaceholderstring"Search…"
searchLabelstring"Search rows"accessible name of the search box
emptyTextstring"No rows."
captionstring—
serverboolean—rows are one server page; sort / query / page are yours to fetch with (see `state` event)
totalnumber—server mode: total row count
loadingboolean—

Events

NamePayloadDescription
state[s: { sortKey: string | null; sortDir: "asc" | "desc"; query: string; page: number; pageSize: number; }]
update:selected[rows: T[]]
rowClick[row: T]

Slots

NameScopeDescription
toolbar{ state: { sortKey: string | null; sortDir: "asc" | "desc"; page: number; pageSize: number; query: string; selected: Set<string | number> & Omit<Set<string | number>, keyof Set<any>>; hidden: Set<string> & Omit<Set<string>, keyof Set<any>>; }; selected: T[]; }

Released under the MIT License. Character names and artwork belong to their owners.