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
| Status | |||||
|---|---|---|---|---|---|
| 1 | 第1話 プロローグ | 2017-04-01 | 1,200 | aired | |
| 2 | 第2話 運命の出会い | 2017-04-02 | 1,658 | aired | |
| 3 | 第3話 フラグの立たない | 2017-04-03 | 1,729 | aired | |
| 4 | 第4話 冴えない彼女 | 2017-04-04 | 1,382 | aired | |
| 5 | 第5話 同人誌 | 2017-04-05 | 970 | aired |
23 rows
Server mode
| No rows. | ||
0 rows
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
rowsitself. Withserver,rowsis one page: listen to@state(sort, query, page, page size) and fetch; settotalandloadingwhile 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"). @rowClickis 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
| Name | Type | Default | Description |
|---|---|---|---|
columns* | BlessDataColumn<T>[] | — | |
rows* | T[] | — | |
rowKey* | keyof T & string | — | |
pageSize | number | 10 | |
pageSizes | number[] | [10, 25, 50] | |
selectable | boolean | — | |
searchable | boolean | — | |
searchKeys | (keyof T & string)[] | — | |
searchPlaceholder | string | "Search…" | |
searchLabel | string | "Search rows" | accessible name of the search box |
emptyText | string | "No rows." | |
caption | string | — | |
server | boolean | — | rows are one server page; sort / query / page are yours to fetch with (see `state` event) |
total | number | — | server mode: total row count |
loading | boolean | — |
Events
| Name | Payload | Description |
|---|---|---|
state | [s: { sortKey: string | null; sortDir: "asc" | "desc"; query: string; page: number; pageSize: number; }] | |
update:selected | [rows: T[]] | |
rowClick | [row: T] |
Slots
| Name | Scope | Description |
|---|---|---|
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[]; } |