Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

List Descriptor

The list half of a resource file: its columns, search, ordering, paging and the capabilities it offers. The resource keys around it are on Form Descriptor.

# descriptors/posts.yaml
entity: posts
path: /posts
title: Posts
permission: acme.blog.manage_posts
list:
  creatable: true
  deletable: true
  exportable: true
  order_by: created_at
  order_dir: desc
  per_page: 25
  per_page_options: [25, 50, 100]
  no_records_message: No posts yet.
  search: { prompt: Search posts }
  columns:
    title:      { searchable: true }
    status:     { type: status_pill, width: 10%, labels: [{ value: draft, label: Draft }] }
    created_at: { type: datetime, align: right }
  filters:
    status: { type: select, options: [{ value: draft, label: Draft }] }
  toolbar:
    - { label: Archive, href: /posts/archive, icon: archive, primary: false }

Set the list’s keys

KeyDefaultDescription
columnsThe columns, keyed by field name, in order. Required.
relatednoneOne-to-one records a column can be read from, by name.
titlethe resource’sThe screen title.
order_by, order_dirid, descThe first sort; asc or desc.
per_page25Rows a page.
per_page_optionsnonePage sizes offered in the list setup; empty offers no choice.
creatablefalseOffers New.
deletablefalseRows can be selected and deleted, and a record’s edit page offers Delete.
protectednoneA boolean column; a row it marks has no checkbox and no Delete.
exportablefalseOffers the export menu. See Export.
searchonThe search box; keys below.
filtersnoneFilters above the table, keyed by field name. See Filters.
no_records_message“No records yet.”Shown when the list has no records at all.
row_clickopenWhere a click on a row goes: open (the record’s edit page), preview (its preview), none, or an address pattern. See below.
remembertrueThe sort, search, filters and page a user last used come back when they return.
reorderofftrue orders rows by sort_order; { column: position } names the column. See Trees and Reordering.
treeofftrue nests rows on parent_id; { parent_key, source } names the column and a picker source for Move to. See Trees and Reordering.
toolbarnoneExtra buttons beside New; keys below.

import is a resource key beside list: see Bulk Import.

KeyDefaultDescription
search.enabledtruefalse removes the box.
search.prompt“Search”The placeholder.
search.on_enterfalseAsk on Enter only.
toolbar[].labelThe button’s text. Required.
toolbar[].hrefA path under the admin root, or an absolute URL. Required.
toolbar[].iconnoneAn icon name from the shared set.
toolbar[].permissionnoneHidden from a user who lacks it.
toolbar[].primarytrue renders it as the prominent action. Required.

Send a row click anywhere

list:
  row_click: "acme/orders/{id}/summary"
list:
  row_click: "https://track.acme.com/parcels/{tracking_code}?order={id}"
PatternGoes to
acme/orders/{id}/summaryA path under the admin root.
/shop/orders/{id}A path on the site.
https://...A full address.
PlaceholderFills in
{id}The record’s id.
{column}A column on the list, as stored, URL-encoded.

A row with an empty value for a placeholder opens nothing. A record in the trash opens nothing.

ListConfig::new("orders", t!("Orders"), columns)
    .row_click(RowClick::Url("acme/orders/{id}/summary".into()));

Name a column

Columns are a map. The key is the name, and they render in the order written:

columns:
  title: {}
  created_at: { type: datetime }

A missing label is made from the key: created_at becomes “Created at”. It is still translatable, and lat i18n extract finds it, as it finds the label of every entry under a column’s labels.

Set a column’s keys

KeyDefaultDescription
labelfrom the keyThe header.
typetextThe column type. Every type: List Columns.
sortabletrueThe header sorts. Empty values come last either way.
invisiblefalseHidden until the user picks it from the column chooser.
widthsharedA CSS width, 10% or 120px.
alignleft, center, right.
permissionnoneA user without it does not see the column; it is then not queried, sorted, searched, picked or exported for them.
searchabletext columnsWhether the search box looks in this column.
labelsnoneWhat a stored value reads as: [{ value: login_success, label: Signed in }]. A value not listed shows as stored.
editablefalseThe cell is the form field’s control, saved on change. The field must be on the resource’s form.
relatednoneThe record under the list’s related the column is read from.
# descriptors/authors.yaml
list:
  related:
    profile: { entity: profiles, foreign_key: author_id }
    address: { entity: addresses, belongs_to: address_id }
  columns:
    name: {}
    city: { related: address }
    bio: { related: profile, sortable: false }
ListConfig::new(
    "authors",
    t!("Authors"),
    vec![
        ListColumn::new("name", t!("Name")),
        ListColumn::new("city", t!("City")).related("address"),
    ],
)
.related("address", RelatedRecord::belongs_to("addresses", "address_id"));

The key is the related table’s column. The column sorts, searches and exports as the list’s own do. related takes the keys of a form’s related.

A key the framework does not know is refused with its line; lat doctor names it without a build.