Skip to main content

Column

Trait Column 

Source
pub trait Column<M>: Send + Sync {
Show 14 methods // 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 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> { ... } 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()
    }
}

Only name, label and text are required.

Required Methods§

Source

fn name(&self) -> &str

The column’s identifier, distinct within its table.

Source

fn label(&self) -> Text

The header text.

Source

fn text(&self, cx: &Cx, row: &M) -> String

The row’s value as plain text.

Provided Methods§

Source

fn cell<'a>(&self, cx: &'a Cx, row: &M) -> BoxView<'a>

The row’s table cell.

Source

fn entry<'a>(&self, cx: &'a Cx, row: &M) -> BoxView<'a>

The record’s entry on a detail page: the label over the cell.

Source

fn column_width(&self) -> ColumnWidth

The width the column claims.

Source

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.

Source

fn alignment(&self) -> Alignment

Where the header and the cells align their content.

Source

fn is_searchable(&self) -> bool

Whether the column joins the table’s search.

Source

fn search_expr(&self, _term: &str) -> Option<Expr<bool>>

The predicate a search for term adds.

Source

fn is_sortable(&self) -> bool

Whether the header links to a sort on this column.

Source

fn order_by(&self, _descending: bool) -> Option<OrderByExpr>

The ordering a sort on this column applies.

Source

fn includes(&self) -> Includes<M>

The relations text, cell and entry read.

Source

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".

Implementors§

Source§

impl<M, T> Column<M> for ColorColumn<M, T>
where M: Model + Send + Sync + 'static, T: FormScalar + Send + Sync + 'static,

Source§

impl<M, T> Column<M> for DateColumn<M, T>
where M: Model + Send + Sync + 'static, T: DateValue,

Source§

impl<M, T> Column<M> for EmbeddedColumn<M, T>
where M: Model + Send + Sync + 'static, T: EmbeddedForm + Send + Sync + 'static,

Source§

impl<M, T> Column<M> for ImageColumn<M, T>
where M: Model + Send + Sync + 'static, T: FormScalar + Send + Sync + 'static,

Source§

impl<M, T> Column<M> for RepeaterColumn<M, T>
where M: Model + Send + Sync + 'static, T: FormInput,

Source§

impl<M, T> Column<M> for RichTextColumn<M, T>
where M: Model + Send + Sync + 'static, T: FormScalar + Send + Sync + 'static,

Source§

impl<M, T> Column<M> for TextColumn<M, T>
where M: Model + Send + Sync + 'static, T: Send + Sync + 'static,

Source§

impl<M> Column<M> for BooleanColumn<M>
where M: Model + Send + Sync + 'static,

Source§

impl<M> Column<M> for ComputedColumn<M>
where M: Model + Send + Sync + 'static,

Source§

impl<M> Column<M> for CountColumn<M>
where M: Model + Send + Sync + 'static,

Source§

impl<M> Column<M> for FileColumn<M>
where M: Model + Send + Sync + 'static,

Source§

impl<M> Column<M> for RelationColumn<M>
where M: Model + Send + Sync + 'static,