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 as OptionSource>::Model>>>,
) -> CountColumn<M>where
S: OptionSource,
pub fn of<S>(
relation: RelationLens<M, Deferred<Vec<<S as OptionSource>::Model>>>,
) -> CountColumn<M>where
S: OptionSource,
Declare a column counting the records of relation that S shows.
Sourcepub fn unscoped<T>(
relation: RelationLens<M, Deferred<Vec<T>>>,
) -> CountColumn<M>
pub fn unscoped<T>( relation: RelationLens<M, Deferred<Vec<T>>>, ) -> CountColumn<M>
Declare a column counting every record of relation, under no resource’s query or
policy: for a related model no resource administers. A count shows no field of the
records.
Source§impl<M> CountColumn<M>
impl<M> CountColumn<M>
Sourcepub fn label(self, label: impl Into<Text>) -> CountColumn<M>
pub fn label(self, label: impl Into<Text>) -> CountColumn<M>
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) -> CountColumn<M>
pub fn width(self, width: ColumnWidth) -> CountColumn<M>
Declare this column’s width.
Sourcepub fn toggleable(self) -> CountColumn<M>
pub fn toggleable(self) -> CountColumn<M>
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 CountColumn<M>
impl<M> Clone for CountColumn<M>
Source§fn clone(&self) -> CountColumn<M>
fn clone(&self) -> CountColumn<M>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more