pub struct CountColumn<M> { /* private fields */ }Expand description
A column counting the records of a Deferred has_many field that a source S shows, a
many-to-many #[has_many(via = ..)] one included.
use tablo_core::{CountColumn, relation};
CountColumn::of::<CommentResource>(relation!(Post.comments));The header and the column’s name are the field’s name, capitalized, until
label replaces both.
The column loads no related record. Once a page’s rows load, it counts each row’s records in
the database, one count query per row: what S’s
scoped_query returns of them when it
lists for the user, as a relationship choice over S offers them. A
request S does not list for, and a row loaded around the table’s or the
Detail’s loader, which runs the counts, renders empty.
unscoped counts every related record.
A panel refuses a count over a related model whose primary key spans several columns.
Implementations§
Source§impl<M> CountColumn<M>
impl<M> CountColumn<M>
Sourcepub fn of<S>(relation: RelationLens<M, Deferred<Vec<S::Model>>>) -> Selfwhere
S: OptionSource,
pub fn of<S>(relation: RelationLens<M, Deferred<Vec<S::Model>>>) -> Selfwhere
S: OptionSource,
Declare a column counting the records of relation that S shows.
Source§impl<M> CountColumn<M>
impl<M> CountColumn<M>
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, 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.
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.