pub async fn record_table<R>(
cx: &Cx,
table: RecordTable<<R as Resource>::Model>,
) -> Result<Pin<Box<dyn View + '_>>, Error>where
R: Resource,Expand description
table over R’s records, for a Widget’s body: the rows under R’s list
columns, each linking its View and Edit pages as R‘s policy allows, with a link to the full
list. Two record tables of one resource on a page take distinct headings, which keep their
rows’ DOM ids apart. It renders nothing when the request may not open that list, the check
can_list makes, or may see none of its columns’ fields.
The rows are the ones the list would show: scoped_query’s, the
caller’s tenant, R’s query and no trashed record, which
table’s filter narrows. Its columns hide what
field_access hides from the request, on R and on the
related records they show, as the list does. It never pages, sorts, searches or writes, so it
adds no route: a record’s own page and the list do.
impl Widget for LatestPosts {
fn declare() -> WidgetDef {
WidgetDef::new().access(can_list::<PostResource>)
}
async fn render(cx: &Cx) -> Result<impl View> {
let table = RecordTable::new()
.heading("Latest posts")
.order_by(Post::fields().created_at().desc());
tablo::record_table::<PostResource>(cx, table).await
}
}§Errors
A column R’s list declares no column for, and the database’s,
when the load fails.