Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module Mosaic_ui.Table
Data table with columns, rows, keyboard navigation, and selection.
Focusable data table with column headers and row selection.
A table widget that displays rows of cell values in typed columns. The widget is keyboard- and mouse-navigable and automatically scrolls to keep the selected row visible.
Keyboard and mouse navigation
Keyboard bindings:
Up/Down arrows move the selection by one row. Shift+Up/Down skips by Props.t's fast_scroll_step rows.
j/k move the selection by one row.
Enter or KP_enter activates the current row, firing the set_on_activate callback.
header is the column header text displayed in the header row. width, alignment, and overflow govern sizing and rendering. min_width and max_width constrain width values of `Auto and `Flex; they are ignored for `Fixed columns.
val column :
?width:width->?alignment:alignment->?overflow:overflow->?min_width:int ->?max_width:int ->string ->column
column header is a column specification with header as the header text and with:
width the column width strategy. Defaults to `Auto.
alignment the horizontal text alignment. Defaults to `Left.
overflow the overflow handling strategy. Defaults to `Ellipsis.
min_width the minimum column width in terminal columns, applied to `Auto and `Flex columns. Defaults to None.
max_width the maximum column width in terminal columns, applied to `Auto and `Flex columns. Defaults to None.
Cell content
type cell
The type for table cells. A cell holds either plain text or rich styled fragments (see cell and rich).
create ~parent () is a table node attached to parent.
The node is focusable and uses buffered rendering. All optional arguments correspond to fields of Props.t; their defaults match those of Props.make. See Props.make for a full description of each parameter.
set_rows t data replaces the data rows of t with data, clamping the selection index to the new valid range. Does not fire the set_on_change callback. Triggers a re-render.
set_selected_row t i selects row i in t, clamping i to the valid range [0; row_count t - 1]. Fires the set_on_change callback when the index actually changes.
set_wrap_selection t v enables (true) or disables (false) selection wrapping at row boundaries for t. When enabled, moving past the last row wraps to the first, and vice versa.
set_fast_scroll_step t n sets the number of rows to skip on Shift+Up/Down in t to n. Values below 1 are clamped to 1.
Callbacks
val set_on_change : t->(int -> unit) option-> unit
set_on_change t cb registers cb as the callback to invoke when the selected row of t changes. cb receives the new 0-based row index. Pass None to remove the callback.
val set_on_activate : t->(int -> unit) option-> unit
set_on_activate t cb registers cb as the callback to invoke when the current row is activated via Enter or KP_enter. cb receives the activated 0-based row index. Pass None to remove the callback.