Table
A component that renders a Table, with sorting capabilities
Columns can be built using the tableColumn
helper, which provides a type-safe API as well as
default implementations for commonly used columns.
Also, when building the data to pass to the table, it's recommended to define columns
as a
const, as opposed to inline, in order to get better type inference, e.g.:
// Best
const columns = [tableColumn(...), tableColumn(...)] as const
<Table columns={columns} data={data} />
// Ok, but worse type inference
<Table columns={[tableColumn(...), tableColumn(...)]} data={data} />
Example
Props
Name | Type | Default Value | Required | Description |
---|---|---|---|---|
columns | readonly Column<string, any, any>[] | readonly GroupedColumn<string, any, any>[] | Yes | ||
data | readonly Row<C>[] | Yes | ||
groupBy | string | No | ||
noResultsTitle | string | No | ||
noResultsDescription | string | No | ||
noResultsFeedbackSize |
| large | No | |
initialSorting | SortingRule<C>[] | No | ||
stickyHeaders | boolean | No | ||
stickyFooters | boolean |
| No | |
height | { custom: string | number; } | No | ||
onRowPress | (row: Row<Row<C>>) => void | No | ||
virtualizeRows | boolean | { estimateRowHeight: (index: number) => number; } | No | ||
customSorting | (rows: Row<Row<C>>[], sortFns: SortFn<C>[]) => Row<Row<C>>[] | No |
The sorting is still performed by the table, in an uncontrolled fashion. This function must be memoized to avoid infinite re-renderings | |
onSort | (sortBy: SortingRule<C>[]) => void | No |
If This function must be memoized to avoid infinite re-renderings |