Skip to content

Caelrik\Ui\Components\Grid ​

Column ​

final class Caelrik\Ui\Components\Grid\Column

Methods ​

__construct ​

php
__construct(string $field, ?string $title = null)

make ​

php
static make(string $field, ?string $title = null): self

sortable ​

php
sortable(bool $sortable = true): self

searchable ​

php
searchable(bool $searchable = true): self

hidden ​

php
hidden(bool $hidden = true): self

Hidden columns are still sent to the client (e.g. an id for row actions).

toggleable ​

php
toggleable(bool $toggleable = true): self

With Grid::columnToggle(): false keeps the column always shown, out of the Columns menu.

initiallyHidden ​

php
initiallyHidden(bool $initiallyHidden = true): self

With 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 ​

php
className(string $className): self

width ​

php
width(string $width): self

filter ​

php
filter(?Filter $filter): self

A 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 ​

php
total(?string $function = Caelrik\Ui\Data\Aggregate::SUM, ?int $decimals = null): self

A 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 ​

php
getTotal(): ?string

getTotalDecimals ​

php
getTotalDecimals(): ?int

editable ​

php
editable(?Editor $editor = null): self

Lets 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 ​

php
getEditor(): ?Editor

getFilter ​

php
getFilter(): ?Filter

getField ​

php
getField(): string

getTitle ​

php
getTitle(): string

isSortable ​

php
isSortable(): bool

isSearchable ​

php
isSearchable(): bool

isVisible ​

php
isVisible(): bool

toArray ​

php
toArray(): array

Editor ​

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 ​

ConstantValue
TEXT'text'
NUMBER'number'
SELECT'select'
BOOLEAN'boolean'
DATE'date'

Methods ​

text ​

php
static text(?int $maxLength = null): self

number ​

php
static number(int|float|null $min = null, int|float|null $max = null, int|float|null $step = null): self

select ​

php
static select(array $options): self

boolean ​

php
static boolean(): self

date ​

php
static date(): self

A day, written Y-m-d.

required ​

php
required(bool $required = true): self

A value is needed: the cell cannot be emptied.

getType ​

php
getType(): string

getOptions ​

php
getOptions(): array

parse ​

php
parse(string $field, mixed $raw, array $messages): string|int|float|bool|null

Reads 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 ​

php
editValue(mixed $value): ?string

The value an editor starts from, from a row's value: '1' or '0' for yes or no, a day for a date.

toArray ​

php
toArray(): array

Filter ​

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 ​

ConstantValue
TEXT'text'
SELECT'select'
BOOLEAN'boolean'
DATE_RANGE'dateRange'

Methods ​

text ​

php
static text(): self

select ​

php
static select(array $options): self

boolean ​

php
static boolean(): self

dateRange ​

php
static dateRange(): self

getType ​

php
getType(): string

getOptions ​

php
getOptions(): array

toArray ​

php
toArray(): array

Released under the MIT License.