pub trait Column<M>: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn label(&self) -> Text;
fn text(&self, cx: &Cx, row: &M) -> String;
// Provided methods
fn cell<'a>(&self, cx: &'a Cx, row: &M) -> BoxView<'a> { ... }
fn entry<'a>(&self, cx: &'a Cx, row: &M) -> BoxView<'a> { ... }
fn column_width(&self) -> ColumnWidth { ... }
fn toggle(&self) -> ColumnToggle { ... }
fn alignment(&self) -> Alignment { ... }
fn search_expr(&self, _term: &str) -> Option<Expr<bool>> { ... }
fn order_by(&self, _descending: bool) -> Option<OrderByExpr> { ... }
fn includes(&self) -> Includes<M> { ... }
fn reads(&self) -> Option<Reads<M>> { ... }
}Expand description
One column of a table or a Detail declares its label, its value read off
the record, and its query predicates.
struct Initials;
impl Column<User> for Initials {
fn name(&self) -> &str {
"initials"
}
fn label(&self) -> Text {
"Initials".into()
}
fn text(&self, _cx: &Cx, 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 toggle(&self) -> ColumnToggle
fn toggle(&self) -> ColumnToggle
Whether each reader may hide or show the column in their list, and how it starts. A detail page shows every column.
Sourcefn search_expr(&self, _term: &str) -> Option<Expr<bool>>
fn search_expr(&self, _term: &str) -> Option<Expr<bool>>
The predicate a search for term adds, or None when the column does not join the table’s
search. A column that joins it answers Some for every non-empty, trimmed term.
Sourcefn order_by(&self, _descending: bool) -> Option<OrderByExpr>
fn order_by(&self, _descending: bool) -> Option<OrderByExpr>
The ordering a sort on this column applies, or None when the header does not link to a
sort on it. A sortable column answers Some either way.
Sourcefn reads(&self) -> Option<Reads<M>>
fn reads(&self) -> Option<Reads<M>>
The fields of the row text, cell,
entry, search_expr and
order_by read, or None when the column does not say.
A panel drops a column reading a field
field_access hides from the user, and refuses to
mount a panel restricting a field whose columns answer None. The built-in columns
answer their own field.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".