pub struct RecordTable<M> { /* private fields */ }Expand description
A few of a resource’s records as a table for a Widget’s body, under the resource’s own
columns: the newest posts, the orders awaiting review. record_table
loads and renders it.
use tablo_core::{RecordTable, lens};
RecordTable::new()
.heading("Latest posts")
.column(lens!(Post.title))
.column(lens!(Post.created_at))
.order_by(Post::fields().created_at().desc())
.limit(5);Implementations§
Source§impl<M> RecordTable<M>
impl<M> RecordTable<M>
Sourcepub fn new() -> Self
pub fn new() -> Self
A table of the resource’s first DEFAULT_RECORD_ROWS records in the database’s order,
under the columns its list shows by default and its plural label.
Sourcepub fn heading(self, heading: impl Into<Text>) -> Self
pub fn heading(self, heading: impl Into<Text>) -> Self
The heading over the table, in place of the resource’s plural label.
Sourcepub fn description(self, description: impl Into<Text>) -> Self
pub fn description(self, description: impl Into<Text>) -> Self
The line under the heading.
Sourcepub fn column<T>(self, path: impl Into<Path<M, T>>) -> Selfwhere
M: Model,
pub fn column<T>(self, path: impl Into<Path<M, T>>) -> Selfwhere
M: Model,
Show the list’s column of the field path names, after the columns given before: once a
table names one, it shows only the columns it names, in that order, a hidden-by-default
one included. path is a Lens, a field path, or a relation’s path,
Post::fields().author(). A field the list declares no column for fails the render; a
column whose field the request may not see is left out.
Sourcepub fn column_named(self, name: impl Into<String>) -> Self
pub fn column_named(self, name: impl Into<String>) -> Self
Sourcepub fn filter(self, filter: Expr<bool>) -> Self
pub fn filter(self, filter: Expr<bool>) -> Self
Only the records filter admits, among those the request may see.
Sourcepub fn order_by(self, order: impl Into<OrderBy>) -> Self
pub fn order_by(self, order: impl Into<OrderBy>) -> Self
Order the records by order, after any order given before: Post::fields().created_at() .desc() lists the newest first.
Sourcepub fn limit(self, rows: usize) -> Self
pub fn limit(self, rows: usize) -> Self
List at most rows records, at least one and at most MAX_RECORD_ROWS.