pub struct TextColumn<M, T> { /* private fields */ }Expand description
A column of one field, rendered as text and bound through a Lens for sorting and search.
tablo_core::TextColumn::new(tablo_core::lens!(User.name))
.searchable()
.sortable();
tablo_core::TextColumn::new(tablo_core::lens!(User.age))
.sortable()
.format(|age| format!("{age} years"));The cell is the value’s FormScalar::to_label, an Options enum’s label
or any other type’s form spelling, unless format says otherwise. Only a
string field is searchable:
ⓘ
tablo_core::TextColumn::new(tablo_core::lens!(User.age)).searchable();Implementations§
Source§impl<M, T> TextColumn<M, T>where
M: Model,
impl<M, T> TextColumn<M, T>where
M: Model,
Sourcepub fn new(lens: Lens<M, T>) -> Self
pub fn new(lens: Lens<M, T>) -> Self
Bind a column to the field lens reads, which must be one field of the model.
Sourcepub fn format(
self,
format: impl Fn(&T) -> String + Send + Sync + 'static,
) -> Self
pub fn format( self, format: impl Fn(&T) -> String + Send + Sync + 'static, ) -> Self
Render the field’s value through format.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> 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.
Trait Implementations§
Source§impl<M, T> Clone for TextColumn<M, T>
impl<M, T> Clone for TextColumn<M, T>
Source§impl<M, T> Column<M> for TextColumn<M, T>
impl<M, T> Column<M> for TextColumn<M, T>
Source§fn column_width(&self) -> ColumnWidth
fn column_width(&self) -> ColumnWidth
The width the column claims.
Source§fn is_searchable(&self) -> bool
fn is_searchable(&self) -> bool
Whether the column joins the table’s search.
Source§fn is_sortable(&self) -> bool
fn is_sortable(&self) -> bool
Whether the header links to a sort on this column.
Source§fn order_by(&self, descending: bool) -> Option<OrderByExpr>
fn order_by(&self, descending: bool) -> Option<OrderByExpr>
The ordering a sort on this column applies.
Source§impl<M, T> Debug for TextColumn<M, T>
impl<M, T> Debug for TextColumn<M, T>
impl<M, T> IntoColumns<M> for TextColumn<M, T>
Source§impl<M, T> IntoDetail<M> for TextColumn<M, T>
impl<M, T> IntoDetail<M> for TextColumn<M, T>
fn into_detail(self) -> Detail<M>
Auto Trait Implementations§
impl<M, T> !Freeze for TextColumn<M, T>
impl<M, T> !RefUnwindSafe for TextColumn<M, T>
impl<M, T> !UnwindSafe for TextColumn<M, T>
impl<M, T> Send for TextColumn<M, T>
impl<M, T> Sync for TextColumn<M, T>
impl<M, T> Unpin for TextColumn<M, T>
impl<M, T> UnsafeUnpin for TextColumn<M, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more