Data Table
An unstyled data table supporting stable sorting, global and column filtering, column visibility, pagination, and row selection.
Base Data Table builds stable sorting, global and per-column filtering, column visibility, pagination, and row selection on top of passive table structure. Supply records with unique id values; row slots map each index on the active page to the underlying record.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Composed recipe with filtering, column visibility, page selection, and custom cell formatting:
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Header and body rows
Section titled “Header and body rows”- Place sortable column headers inside
DataTableHeaderRow, and render body record slots withDataTableRowindexed for the current page. - Each
Cellrenders itscolumnKeyfrom the active record so sorting and pagination update cell content directly.
Filtering, column visibility, page selection, and custom formatting
Section titled “Filtering, column visibility, page selection, and custom formatting”- Filtering: every non-empty
columnFiltersentry combines with Rootfilterbefore sorting and pagination run. - Column visibility:
columnVisibilityhides matchingHeaderandCellviews (removing them from sorting focus and accessibility output) while preserving their identity when shown again. - Page selection:
requestPageSelection()selects or clears only the current filtered page while preserving selections on other pages, and reportspageSelectionas'none','some', or'all'.readOnlyblocks row and page selection while allowing sorting and pagination. - Custom cell rendering: set
renderValue={false}on aCellto keep your own child elements while subscribing to its publicdisplayValuestate for custom formatting.
Root Props
Section titled “Root Props”Pass sortKey, sortDirection, page, or selectedKeys to control the corresponding state.
| Prop | Type | Default |
|---|---|---|
rows | readonly DataRecord[] | [] |
defaultSortKey | string | '' |
defaultSortDirection | 'none' 'ascending' 'descending' | none |
filter | string | '' |
columnFilters | Readonly<Record<string, string>> | {} |
columnVisibility | Readonly<Record<string, boolean>> | {} |
defaultPage | number | 0 |
pageSize | number | 10 |
defaultSelectedKeys | readonly string[] | [] |
disabled | boolean | false |
readOnly | boolean | false |
Other parts
Section titled “Other parts”- Row:
indexdefaults to0,headertofalse. - Cell:
columnKeydefaults to'',renderValuetotrue. - Header:
sortabledefaults totrue. - Previous / Next: accept Button props.