ProgressColumn
Progress as a thin bar with its text: a percentage, or done of total, e.g. the ticked items of a checklist.
use Anvil\Collection\Columns\ProgressColumn;
// a percentage of the record (0–100): "60 %"ProgressColumn::make('progress'),
// done of total: "3/5"ProgressColumn::make('steps')->label('Steps') ->state(fn (array $order): array => [$order['steps_done'], $order['steps_total']]),| Value | Shows |
|---|---|
| a number | a percentage; values below 0 or above 100 are capped |
[done, total] or ['done' => …, 'total' => …] |
done/total, e.g. 3/5 |
null, or a total of 0 |
nothing |
A finished bar (100 %, or done equal to total) is green.
Checklists
Section titled “Checklists”checklist() shows the ticked items of the checklist
of the record, counted for a page in one query:
ProgressColumn::make('checklist')->label('Checklist')->checklist(),The column also takes the
options of every column. To
sort by progress, store it in a column or compute it in scopeQuery() and
add queryColumn(), see
Computed values.
Display and export
Section titled “Display and export”- The bar is a
<progress>element without inline styles (Content Security Policy). Screen readers read the text next to it. - Exports contain percentages as numbers and pairs as text (
3/5).