pub trait Column<M>: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn label(&self) -> &str;
fn text(&self, row: &M) -> String;
// Provided methods
fn cell<'a>(&self, cx: &'a Cx, row: &M) -> BoxView<'a> { ... }
fn column_width(&self) -> ColumnWidth { ... }
fn is_searchable(&self) -> bool { ... }
fn search_expr(&self, _term: &str) -> Option<Expr<bool>> { ... }
fn is_sortable(&self) -> bool { ... }
fn order_by(&self, _descending: bool) -> Option<OrderByExpr> { ... }
fn includes(&self) -> Includes<M> { ... }
}Expand description
One table column declares its header, its cell, and its query predicates.
struct Initials;
impl Column<User> for Initials {
fn name(&self) -> &str {
"initials"
}
fn label(&self) -> &str {
"Initials"
}
fn text(&self, row: &User) -> String {
row.name
.split_whitespace()
.filter_map(|w| w.chars().next())
.collect()
}
}Required Methods§
Provided Methods§
Sourcefn column_width(&self) -> ColumnWidth
fn column_width(&self) -> ColumnWidth
The width the column claims.
Sourcefn is_searchable(&self) -> bool
fn is_searchable(&self) -> bool
Whether the column joins the table’s search.
Sourcefn is_sortable(&self) -> bool
fn is_sortable(&self) -> bool
Whether the header links to a sort on this column.
Sourcefn order_by(&self, _descending: bool) -> Option<OrderByExpr>
fn order_by(&self, _descending: bool) -> Option<OrderByExpr>
The ordering a sort on this column applies.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".