Skip to main content

table

Function table 

Source
pub fn table<'a>(
    ui: &mut Ui,
    columns: &'a [Column<'a>],
    body: &Body<'_>,
    sizing: &Sizing<'_>,
    palette: &Palette,
    style: &TableStyle,
    draw: impl FnMut(&mut Ui, &'a Column<'a>, usize),
) -> Option<&'a Column<'a>>
Expand description

A described table, narrowed for the width available.

draw is called once per cell of each kept column, in column order, for each of Body::rows rows. Taking a closure rather than a slice of contents is what keeps the app’s own data borrowed one cell at a time, which is group’s reasoning and immediate mode’s habit.

body is borrowed immutably and draw is FnMut, which is the split a caller has to plan for: a selection read by Body::selected cannot be the same value draw mutates. Snapshot it before the call. That is not this crate imposing anything. It is the borrow the app already takes when it clones its row list to hand egui a closure.

Returns the sortable column whose heading was pressed this frame, if any. The app owns the ordering, so this reports the press and changes nothing: what a press calls is an address, and the description names none. That is Column::sortable’s own documented split.

A heading is only pressable when its column says sortable. A column sorted by a key the user cannot change still draws its caret and does not answer.