pub struct ToggleColumn<M> { /* private fields */ }Expand description
A column of a bool field rendered as a switch that saves the record when it flips.
tablo_core::ToggleColumn::new(tablo_core::lens!(Post.featured));See Editing in a cell for where the switch renders and what it posts.
§Editing in a cell
A list, a relation table or a widget’s record table renders the control on a row whose record the user may update and that is not in the trash, for a field the user may change; anywhere else, and on a detail page, the cell shows the value. The control posts its field alone to the record’s edit route, with the record’s version, so the save runs every check the edit page’s does and lands back on the table. A refused value opens the edit page with its errors.
The mount refuses the column unless the resource’s form edits the field with the matching control, a checkbox or switch here, shown and enabled whatever the other fields hold. Flipping the switch and changing a select save through the runtime’s one line of script; a text input saves on Enter.
The control spells the value as the field’s form spelling, as a derived record form does, so a
hand-written RecordForm must read the key as that spelling.
Implementations§
Source§impl<M> ToggleColumn<M>where
M: Model,
impl<M> ToggleColumn<M>where
M: Model,
Sourcepub fn label(self, label: impl Into<Text>) -> Self
pub fn label(self, label: impl Into<Text>) -> Self
Replace the label the field’s name gives it.
Sourcepub fn width(self, width: ColumnWidth) -> Self
pub fn width(self, width: ColumnWidth) -> Self
Declare this column’s width.
Sourcepub fn toggleable(self) -> Self
pub fn toggleable(self) -> Self
Let each reader hide this column from their list; it starts shown.
Let each reader show this column in their list; it starts hidden.
Trait Implementations§
Source§impl<M> Clone for ToggleColumn<M>
impl<M> Clone for ToggleColumn<M>
Source§impl<M> Column<M> for ToggleColumn<M>
impl<M> Column<M> for ToggleColumn<M>
Source§fn column_width(&self) -> ColumnWidth
fn column_width(&self) -> ColumnWidth
Source§fn toggle(&self) -> ColumnToggle
fn toggle(&self) -> ColumnToggle
Source§fn order_by(&self, descending: bool) -> Option<OrderByExpr>
fn order_by(&self, descending: bool) -> Option<OrderByExpr>
None when the header does not link to a
sort on it. A sortable column answers Some either way.