Skip to main content

Module tree_table_view

Module tree_table_view 

Source
Expand description

TreeTableView<T> — hierarchical multi-column data table with expand/collapse.

Sibling of TableView for tree-shaped data. Each row carries a depth level; one designated column (the tree column, defaulting to the first) shows a twist (chevron) and an indent gutter that toggles the row’s children. Backed by a SortFilterTreeModel<T> so sort, filter, and expand state compose without extra bookkeeping. Shares the header, column, keyboard, and selection modules with TableView.

Rows live in a TreeBodyPane — a sibling of the scrollbar — so buffer-exit / selection / expand rebuilds are never deferred mid-thumb-drag. Three row-height modes: uniform (row_height, fast path), exact per-flat-index callback (row_height_fn), and auto-measured (auto_row_height — grows to tallest cell).

§Common patterns

A checkbox column. Selection and “checked” are different things — a checkbox column wants its own state, with parent/child propagation. Build it from TreeCheckedModel over the same tree the view projects.

A cell delegate receives (&T, &CellContext) and CellContext carries no node identity — only row_index. So capture the projection and resolve the row’s NodeId through it:

let proxy = SortFilterTreeModel::new(tree);
let checks = TreeCheckedModel::new(proxy.tree());
let for_cells = proxy.clone();
let col = Column::new("done", lit!("Done"), move |_item, cx: &CellContext| {
    match for_cells.visible_node_id(cx.row_index) {
        Some(node) => Box::new(Checkbox::new(checks.check_state(node))) as Box<dyn Widget>,
        None => Box::new(Spacer::new()),
    }
});

For a tree whose identity is a domain key rather than a NodeId, use KeyedTreeCheckedModel instead — it survives a full re-source, which a NodeId-keyed set cannot.

§Accessibility

Root emits Role::TreeGrid; rows carry set_level + set_expanded. ArrowLeft / ArrowRight on the tree column collapse / expand.

// Column delegates capture closures — use ignore.
use teksilo_widgets::TreeTableView;
use teksilo_data::TreeModel;
let _view = TreeTableView::new(model).row_height(28.0);

Structs§

TreeTableView
Hierarchical multi-column widget. See module documentation.