Skip to main content

Module data_table

Module data_table 

Source
Available on crate feature data-table only.
Expand description

Records in rows and columns, with sorting, filtering, selection and pages.

State owns the rows, the Columns that read them, and everything the reader changes: the sort, the search and column filters, the page, the selection and which columns are hidden. Its update is pure, so it is tested without a renderer. The view only builds the rows of the current page that are in view, and the header stays put while they scroll.

Narrower than its breakpoint, the table turns into a stack of cards, one per row, with each column as a labelled line, so it never overflows a phone screen.

The table resolves its keys through a Keymap of Actions while it has focus, which it takes when pressed; see default_keymap.

Structs§

Column
One column: its header, how it reads a row, and how it is shown.
DataTable
A data table builder. Convert it into an Element to render.
RowStyle
The colours of a row.
State
The rows, the columns and how the reader is looking at them.
Status
How a row is shown.

Enums§

Action
What a data table keyboard shortcut does.
Align
How a column’s header and cells line up.
Direction
Which way a column is sorted.
Event
Everything that changes a table.
Output
What the app may need to act on after an Event.
Value
A cell’s value, which sorting, searching and filtering read.

Constants§

BREAKPOINT
Below this width, in logical pixels, rows become cards.
CARD_LINE
Height of one labelled line in a card.
HEADER_HEIGHT
Height of the header row.
PAGE_SIZES
The page sizes offered unless the state sets its own.
ROW_HEIGHT
Height of every body row.
SKELETON_ROWS
Placeholder rows shown while loading.

Functions§

column
A sortable, searchable and hideable column that fills an equal share of the width. value reads the cell from a row.
compare
Orders two values: numbers by size, text alphabetically ignoring case, and numbers before text.
data_table
Renders state. Without on_event every control renders disabled.
default_keymap
The default data table shortcuts:
frame_style
The frame around the table: a subtle border with rounded corners.
row_style
Resolves a row’s colours: muted when selected, a lighter tint under the pointer.
skeleton_style
A placeholder bar in a loading row.
sort_glyph
The sort indicator for a column: arrows up and down while unsorted, or the direction.

Type Aliases§

ColumnId
Names a column. Sorting, filters and hiding refer to columns by it.