Skip to main content

RowSource

Trait RowSource 

Source
pub trait RowSource {
    // Required methods
    fn row_count(&self) -> usize;
    fn row(&self, index: usize) -> Vec<Cell>;
    fn column_defs(&self) -> &[ColumnDef];

    // Provided methods
    fn set_cell(
        &mut self,
        _row: usize,
        _col: usize,
        _value: Cell,
    ) -> Result<(), TableError> { ... }
    fn row_height(&self, _index: usize) -> f32 { ... }
    fn children(&self, _row: usize) -> Option<Vec<usize>> { ... }
    fn indent_level(&self, _row: usize) -> usize { ... }
    fn footer(&self) -> Option<Vec<Cell>> { ... }
}
Expand description

Trait that provides rows to the table widget.

Required Methods§

Source

fn row_count(&self) -> usize

Returns the total number of rows in the data source.

Source

fn row(&self, index: usize) -> Vec<Cell>

Returns the cells for row at the given index.

Source

fn column_defs(&self) -> &[ColumnDef]

Returns the column definitions (name + preferred width).

Provided Methods§

Source

fn set_cell( &mut self, _row: usize, _col: usize, _value: Cell, ) -> Result<(), TableError>

Attempt to set a cell value in the source.

The default implementation returns TableError::ReadOnly, marking the source as immutable. Override this method on mutable sources to accept edits committed from the UI.

Source

fn row_height(&self, _index: usize) -> f32

Per-row height in logical pixels.

The default returns DEFAULT_ROW_HEIGHT (24 px) for every row, producing a uniform-height table. Override for variable-height rows.

Source

fn children(&self, _row: usize) -> Option<Vec<usize>>

Optional children of a row, enabling tree / grouped tables.

Returns None for leaf rows and flat (non-grouped) tables (default). Return Some(child_indices) for a row that acts as a parent node.

Source

fn indent_level(&self, _row: usize) -> usize

Indent level for a row in a tree / grouped table.

Returns 0 for root-level rows (default). Override to return 1 for first-level children, 2 for grandchildren, and so on.

Source

fn footer(&self) -> Option<Vec<Cell>>

Optional footer (aggregate) row displayed below the data rows.

Returns None (no footer) by default. Override to return a Vec<Cell> whose length matches column_defs().len().

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: RowSource + ?Sized> RowSource for Box<T>

Blanket impl so that Box<dyn RowSource> itself implements RowSource, enabling object-safe polymorphic table data sources.

Source§

fn row_count(&self) -> usize

Source§

fn row(&self, index: usize) -> Vec<Cell>

Source§

fn column_defs(&self) -> &[ColumnDef]

Source§

fn set_cell( &mut self, row: usize, col: usize, value: Cell, ) -> Result<(), TableError>

Source§

fn row_height(&self, index: usize) -> f32

Source§

fn children(&self, row: usize) -> Option<Vec<usize>>

Source§

fn indent_level(&self, row: usize) -> usize

Source§

fn footer(&self) -> Option<Vec<Cell>>

Implementors§