pub struct RelationColumn<M> { /* private fields */ }Expand description
A column showing the record of a Deferred belongs_to or has_one field as text, or the
records of a has_many one (list), which declares the field’s include so every
page that renders it loads them.
use tablo_core::{RelationColumn, relation};
RelationColumn::new(relation!(Post.author), |a: &Author| a.name.clone());The header and the column’s name are the field’s name, capitalized, until
label replaces both. A nullable field holding no record renders empty. The
column neither searches nor sorts.
The include loads the related row through Toasty alone: the related resource’s query and
policy do not apply, so a soft-deleted or hidden record shows.
Implementations§
Source§impl<M> RelationColumn<M>where
M: Model,
impl<M> RelationColumn<M>where
M: Model,
Sourcepub fn new<T>(
relation: RelationLens<M, impl ToOneRelation<T> + 'static>,
project: impl Fn(&T) -> String + Send + Sync + 'static,
) -> Selfwhere
M: 'static,
pub fn new<T>(
relation: RelationLens<M, impl ToOneRelation<T> + 'static>,
project: impl Fn(&T) -> String + Send + Sync + 'static,
) -> Selfwhere
M: 'static,
Declare a column rendering project of the record relation loads.
Sourcepub fn of<S>(
relation: RelationLens<M, impl ToOneRelation<S::Model> + 'static>,
) -> Selfwhere
S: OptionSource,
M: 'static,
pub fn of<S>(
relation: RelationLens<M, impl ToOneRelation<S::Model> + 'static>,
) -> Selfwhere
S: OptionSource,
M: 'static,
Declare a column showing the record relation loads by S’s
label: for a resource, the
record_title its detail page is titled with.
use tablo_core::{RelationColumn, relation};
RelationColumn::of::<AuthorResource>(relation!(Post.author));Sourcepub fn list<S>(relation: RelationLens<M, Deferred<Vec<S::Model>>>) -> Selfwhere
S: OptionSource,
M: 'static,
pub fn list<S>(relation: RelationLens<M, Deferred<Vec<S::Model>>>) -> Selfwhere
S: OptionSource,
M: 'static,
Declare a column listing the records a has_many relation loads, a many-to-many
#[has_many(via = ..)] one included, each by S’s label, joined
by commas, but the ones S does not let the user view.
use tablo_core::{RelationColumn, relation};
RelationColumn::list::<TagResource>(relation!(Post.tags));Source§impl<M> RelationColumn<M>
impl<M> RelationColumn<M>
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, and name the column after the label,
as a ComputedColumn is: two columns over one relation
need two labels.
Sourcepub fn width(self, width: ColumnWidth) -> Self
pub fn width(self, width: ColumnWidth) -> Self
Declare this column’s width.
Trait Implementations§
Source§impl<M> Clone for RelationColumn<M>
impl<M> Clone for RelationColumn<M>
Source§impl<M> Column<M> for RelationColumn<M>
impl<M> Column<M> for RelationColumn<M>
Source§fn column_width(&self) -> ColumnWidth
fn column_width(&self) -> ColumnWidth
Source§fn is_searchable(&self) -> bool
fn is_searchable(&self) -> bool
Source§fn search_expr(&self, _term: &str) -> Option<Expr<bool>>
fn search_expr(&self, _term: &str) -> Option<Expr<bool>>
term adds.