Skip to main content

TableRow

Trait TableRow 

Source
pub trait TableRow<Column: Copy + Send + Sync + 'static>: Sized {
    type ClassesProvider: TableClassesProvider + Copy;

    const COLUMN_COUNT: usize;

    // Required methods
    fn render_row(
        row: RwSignal<Self>,
        index: usize,
        columns: RwSignal<Vec<Column>>,
    ) -> impl IntoView;
    fn render_head_row<F>(
        sorting: Signal<VecDeque<(Column, ColumnSort)>>,
        on_head_click: F,
        drag_handlers: HeadDragHandler<Column>,
        columns: RwSignal<Vec<Column>>,
    ) -> impl IntoView
       where F: Fn(TableHeadEvent<Column>) + Send + Clone + 'static;
    fn cell_renderer_for_column(
        row: RwSignal<Self>,
        column: Column,
        class: String,
    ) -> impl IntoView;
    fn columns() -> &'static [Column];
    fn col_name(col_index: Column) -> &'static str;

    // Provided method
    fn sorting_to_sql(
        sorting: &VecDeque<(Column, ColumnSort)>,
    ) -> Option<String>
       where Column: Send + Sync + 'static { ... }
}
Expand description

This trait has to be implemented in order for [TableContent] to be able to render rows and the head row of the table. Usually this is done by #[derive(TableRow)].

Please see the simple example for how to use.

Required Associated Constants§

Source

const COLUMN_COUNT: usize

How many columns this row has (i.e. the number of fields in the struct)

Required Associated Types§

Required Methods§

Source

fn render_row( row: RwSignal<Self>, index: usize, columns: RwSignal<Vec<Column>>, ) -> impl IntoView

Renders the inner of one row of the table using the cell renderers. This produces the children that go into the row_renderer given to [TableContent].

This render function has to render exactly one root element.

Source

fn render_head_row<F>( sorting: Signal<VecDeque<(Column, ColumnSort)>>, on_head_click: F, drag_handlers: HeadDragHandler<Column>, columns: RwSignal<Vec<Column>>, ) -> impl IntoView
where F: Fn(TableHeadEvent<Column>) + Send + Clone + 'static,

Render the head row of the table.

Source

fn cell_renderer_for_column( row: RwSignal<Self>, column: Column, class: String, ) -> impl IntoView

Returns the cell renderer for a column Allows to create custom row renders while still using the annotation configured cell renderers.

Source

fn columns() -> &'static [Column]

All columns this row can show in their default order.

Source

fn col_name(col_index: Column) -> &'static str

The name of the column (= struct field name) at the given index. This can be used to implement sorting in a database. Information on column indexes is available at: the Column index type section.

Provided Methods§

Source

fn sorting_to_sql(sorting: &VecDeque<(Column, ColumnSort)>) -> Option<String>
where Column: Send + Sync + 'static,

Converts the given sorting to an SQL statement. Return None when there is nothing to be sorted otherwise Some("ORDER BY ..."). Uses Self::col_name to get the column names for sorting.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§