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 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§
Sourceconst COLUMN_COUNT: usize
const COLUMN_COUNT: usize
How many columns this row has (i.e. the number of fields in the struct)
Required Associated Types§
Required Methods§
Sourcefn render_row(
row: RwSignal<Self>,
index: usize,
columns: RwSignal<Vec<Column>>,
) -> impl IntoView
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.
Sourcefn render_head_row<F>(
sorting: Signal<VecDeque<(Column, ColumnSort)>>,
on_head_click: F,
drag_handlers: HeadDragHandler<Column>,
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
Render the head row of the table.
Sourcefn col_name(col_index: Column) -> &'static str
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§
Sourcefn sorting_to_sql(sorting: &VecDeque<(Column, ColumnSort)>) -> Option<String>
fn sorting_to_sql(sorting: &VecDeque<(Column, ColumnSort)>) -> Option<String>
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", so this trait is not object safe.