Caelrik\Ui\Components\Grid
Column
final class Caelrik\Ui\Components\Grid\Column
Methods
__construct
__construct(string $field, ?string $title = null)make
static make(string $field, ?string $title = null): selfsortable
sortable(bool $sortable = true): selfsearchable
searchable(bool $searchable = true): selfhidden
hidden(bool $hidden = true): selfHidden columns are still sent to the client (e.g. an id for row actions).
toggleable
toggleable(bool $toggleable = true): selfWith Grid::columnToggle(): false keeps the column always shown, out of the Columns menu.
initiallyHidden
initiallyHidden(bool $initiallyHidden = true): selfWith Grid::columnToggle(): hidden until the user shows it in the Columns menu. Unlike hidden(), it is a column to read, only not shown by default.
className
className(string $className): selfwidth
width(string $width): selffilter
filter(?Filter $filter): selfA filter in the grid's filter bar: Filter::text(), select([...]), boolean() or dateRange(). respond() applies it on the server; it works on a column that is not searchable.
total
total(?string $function = Caelrik\Ui\Data\Aggregate::SUM, ?int $decimals = null): selfA total in the grid's footer, over every row that passes the search and filters: 'sum', 'avg', 'count', 'min' or 'max'. A grouped grid (Grid::groupBy()) totals each group too. Without $decimals: none for a count or a whole number, 2 otherwise.
getTotal
getTotal(): ?stringgetTotalDecimals
getTotalDecimals(): ?inteditable
editable(?Editor $editor = null): selfLets the user change the cell in place, with an Editor: text(), number(), select([...]), boolean() or date(). The grid needs an endpoint for the changes (Grid::inlineEdit()).
getEditor
getEditor(): ?EditorgetFilter
getFilter(): ?FiltergetField
getField(): stringgetTitle
getTitle(): stringisSortable
isSortable(): boolisSearchable
isSearchable(): boolisVisible
isVisible(): booltoArray
toArray(): arrayEditor
final class Caelrik\Ui\Components\Grid\Editor
How a grid cell is edited in place (Column::editable()): a text, a number, a choice from a list, yes or no, or a date. The browser checks the value before sending it, and Grid::cellEdit() checks it again on the server with the same rules.
Constants
| Constant | Value |
|---|---|
TEXT | 'text' |
NUMBER | 'number' |
SELECT | 'select' |
BOOLEAN | 'boolean' |
DATE | 'date' |
Methods
text
static text(?int $maxLength = null): selfnumber
static number(int|float|null $min = null, int|float|null $max = null, int|float|null $step = null): selfselect
static select(array $options): selfboolean
static boolean(): selfdate
static date(): selfA day, written Y-m-d.
required
required(bool $required = true): selfA value is needed: the cell cannot be emptied.
getType
getType(): stringgetOptions
getOptions(): arrayparse
parse(string $field, mixed $raw, array $messages): string|int|float|bool|nullReads a value the browser sent, as its column holds it: a trimmed text, an int or a float, an option's value, true or false, or a day written Y-m-d. An empty value is null, unless the editor is required().
- Throws InvalidCellEdit With a message for the user.
editValue
editValue(mixed $value): ?stringThe value an editor starts from, from a row's value: '1' or '0' for yes or no, a day for a date.
toArray
toArray(): arrayFilter
final class Caelrik\Ui\Components\Grid\Filter
A column filter of a Grid, shown in the filter bar above the table:
- text(): rows whose value contains the text, ignoring case;
- select($options): rows whose value is the chosen option;
- boolean(): yes or no, for true/false or 1/0 values;
- dateRange(): rows whose date (Y-m-d, or a date and time) is in the range, both days included.
Constants
| Constant | Value |
|---|---|
TEXT | 'text' |
SELECT | 'select' |
BOOLEAN | 'boolean' |
DATE_RANGE | 'dateRange' |
Methods
text
static text(): selfselect
static select(array $options): selfboolean
static boolean(): selfdateRange
static dateRange(): selfgetType
getType(): stringgetOptions
getOptions(): arraytoArray
toArray(): array