Final Class Yiisoft\Yii\DataView\GridView\GridView
| Inheritance | Yiisoft\ |
|---|
The GridView widget displays data in a grid.
You can configure the columns of the grid table in terms of {@see \
The look and feel of a grid view can be customized using many properties.
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $accessibility | boolean | Whether to add accessibility attributes (such as scope and aria-*) automatically during rendering. |
Yiisoft\ |
| $multiSort | boolean | Yiisoft\ |
|
| $translationCategory | string | Yiisoft\ |
|
| $translator | \ |
A translator instance used for translations of messages. | Yiisoft\ |
| $urlConfig | Yiisoft\ |
Yiisoft\ |
|
| $urlCreator | Yiisoft\ |
||
| $urlParameterProvider | Yiisoft\ |
Yiisoft\ |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| accessibility() | Return a new instance that toggles automatically added accessibility attributes. | Yiisoft\ |
| addColumnRendererConfigs() | Add configurations for a column renderers. | Yiisoft\ |
| addContainerClass() | Adds one or more CSS classes to the existing container classes. | Yiisoft\ |
| addHeaderClass() | Yiisoft\ |
|
| addTableClass() | Add one or more CSS classes to the table tag. |
Yiisoft\ |
| addTbodyClass() | Add one or more CSS classes to the tbody tag. |
Yiisoft\ |
| afterRow() | Returns a new instance with a callback that is executed once AFTER rendering each data row. | Yiisoft\ |
| append() | Returns a new instance with HTML content to be added before the closing container tag. | Yiisoft\ |
| beforeRow() | Return a new instance with a callback that is executed BEFORE rendering each data row. | Yiisoft\ |
| bodyCellAttributes() | Return new instance with the HTML attributes for the td tag. |
Yiisoft\ |
| bodyRowAttributes() | Return new instance with the HTML attributes for body rows of the grid. | Yiisoft\ |
| caption() | Return new instance with the content for the caption tag. |
Yiisoft\ |
| captionAttributes() | Return new instance with the HTML attributes for the caption tag. |
Yiisoft\ |
| columnGrouping() | Returns a new instance with the column grouping enabled. | Yiisoft\ |
| columns() | Return new instance with the specified column configurations. | Yiisoft\ |
| containerAttributes() | Returns a new instance with the HTML attributes for container. | Yiisoft\ |
| containerClass() | Set new container classes. | Yiisoft\ |
| containerTag() | Yiisoft\ |
|
| dataReader() | Yiisoft\ |
|
| emptyCell() | Return new instance with the HTML to display when the content is empty. | Yiisoft\ |
| emptyCellAttributes() | Returns a new instance with the HTML attributes for the empty cell. | Yiisoft\ |
| enableFooter() | Whether to show the footer section of the grid. | Yiisoft\ |
| enableHeader() | Return new instance whether to show the header section of the grid. | Yiisoft\ |
| encodeHeader() | Yiisoft\ |
|
| filterCellAttributes() | Return new instance with the HTML attributes for the filter cell (td) tag. |
Yiisoft\ |
| filterCellInvalidClass() | Return new instance with the CSS class to be added to filter cells that contain invalid values. | Yiisoft\ |
| filterErrorsContainerAttributes() | Return new instance with the HTML attributes for the filter errors container. | Yiisoft\ |
| filterFormAttributes() | Yiisoft\ |
|
| filterFormId() | Yiisoft\ |
|
| filterRowAttributes() | Return new instance with the HTML attributes for the filter row. | Yiisoft\ |
| footerRowAttributes() | Returns a new instance with the HTML attributes for footer row. | Yiisoft\ |
| header() | Return new instance with the header for the grid. | Yiisoft\ |
| headerAttributes() | Return new instance with the HTML attributes for the header. | Yiisoft\ |
| headerCellAttributes() | Return new instance with the HTML attributes for the th tag. |
Yiisoft\ |
| headerClass() | Yiisoft\ |
|
| headerRowAttributes() | Return new instance with the HTML attributes for the header row. | Yiisoft\ |
| headerTag() | Yiisoft\ |
|
| id() | Returns a new instance with the id of the grid view, detail view, or list view. | Yiisoft\ |
| ignoreMissingPage() | Yiisoft\ |
|
| keepColumnAttributesInEmptyCell() | Returns a new instance with a flag defining whether an empty body cell keeps the HTML attributes set by its
column (grid-level {@see bodyCellAttributes()} and column-level bodyAttributes/bodyClass). |
Yiisoft\ |
| keepPageOnSort() | Whether to keep the current page when sorting is changed. | Yiisoft\ |
| keysetPaginationConfig() | Set configuration for keyset pagination widget. | Yiisoft\ |
| layout() | Returns a new instance with the layout of the grid view, and list view. | Yiisoft\ |
| multiSort() | Yiisoft\ |
|
| noResultsCellAttributes() | Yiisoft\ |
|
| noResultsTemplate() | Yiisoft\ |
|
| noResultsText() | Yiisoft\ |
|
| offsetPaginationConfig() | Set configuration for offset pagination widget. | Yiisoft\ |
| pageNotFoundExceptionCallback() | Yiisoft\ |
|
| pageParameterName() | Return a new instance with the name of argument or query parameter for page. | Yiisoft\ |
| pageParameterType() | Creates a new instance with the specified page parameter type. | Yiisoft\ |
| pageSizeAttributes() | Returns a new instance with the HTML attributes for page size wrapper tag. | Yiisoft\ |
| pageSizeConstraint() | Get a new instance with a page size constraint set. | Yiisoft\ |
| pageSizeParameterName() | Return a new instance with the name of argument or query parameter for page size. | Yiisoft\ |
| pageSizeParameterType() | Creates a new instance with the specified page size parameter type. | Yiisoft\ |
| pageSizeTag() | Yiisoft\ |
|
| pageSizeTemplate() | Returns a new instance with the page size template. | Yiisoft\ |
| pageSizeWidget() | Yiisoft\ |
|
| paginationWidget() | Yiisoft\ |
|
| prepareDataReader() | Prepares data reader using current URL parameters, filters, and sorting. | Yiisoft\ |
| prepend() | Returns a new instance with HTML content to be added after the opening container tag. | Yiisoft\ |
| previousPageParameterName() | Yiisoft\ |
|
| previousPageParameterType() | Creates a new instance with the specified previous page parameter type. | Yiisoft\ |
| render() | Yiisoft\ |
|
| sortParameterName() | Creates a new instance with the specified sort parameter name. | Yiisoft\ |
| sortParameterType() | Creates a new instance with the specified sort parameter type. | Yiisoft\ |
| sortableHeaderAppend() | Return new instance with the content to be appended to sortable column headers. | Yiisoft\ |
| sortableHeaderAscAppend() | Return new instance with the content to be appended to ascending sorted column headers. | Yiisoft\ |
| sortableHeaderAscClass() | Return new instance with the CSS class for ascending sorted column headers. | Yiisoft\ |
| sortableHeaderAscPrepend() | Return new instance with the content to be prepended to ascending sorted column headers. | Yiisoft\ |
| sortableHeaderClass() | Return new instance with the CSS class for sortable column headers that are not currently sorted. | Yiisoft\ |
| sortableHeaderDescAppend() | Return new instance with the content to be appended to descending sorted column headers. | Yiisoft\ |
| sortableHeaderDescClass() | Return new instance with the CSS class for descending sorted column headers. | Yiisoft\ |
| sortableHeaderDescPrepend() | Return new instance with the content to be prepended to descending sorted column headers. | Yiisoft\ |
| sortableHeaderPrepend() | Return new instance with the content to be prepended to sortable column headers. | Yiisoft\ |
| sortableLinkAscClass() | Return new instance with the CSS class for links in ascending sorted column headers. | Yiisoft\ |
| sortableLinkAttributes() | Return new instance with the HTML attributes for a link in sortable columns' headers. | Yiisoft\ |
| sortableLinkDescClass() | Return new instance with the CSS class for links in descending sorted column headers. | Yiisoft\ |
| summaryAttributes() | Returns a new instance with the HTML attributes for summary wrapper tag. | Yiisoft\ |
| summaryTag() | Yiisoft\ |
|
| summaryTemplate() | Returns a new instance with the summary template. | Yiisoft\ |
| tableAttributes() | Return new instance with the HTML attributes for the table tag. |
Yiisoft\ |
| tableClass() | Replace current table tag CSS classes with a new set of classes. |
Yiisoft\ |
| tbodyAttributes() | Return new instance with the HTML attributes for the tbody tag. |
Yiisoft\ |
| tbodyClass() | Replace current tbody tag CSS classes with a new set of classes. |
Yiisoft\ |
| toolbar() | Return new instance with toolbar content. | Yiisoft\ |
| urlArguments() | Return a new instance with arguments of the route. | Yiisoft\ |
| urlCreator() | Yiisoft\ |
|
| urlParameterProvider() | Yiisoft\ |
|
| urlQueryParameters() | Return a new instance with query parameters of the route. | Yiisoft\ |
| useInlineJs() | Return a new instance forcing inline JavaScript for every rendered {@see UseInlineJsInterface} widget. | Yiisoft\ |
Protected Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| DEFAULT_TRANSLATION_CATEGORY | 'yii-dataview' | A name for {@see CategorySource} used with translator ({@see TranslatorInterface}) by default. | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $columnRenderersDependencyContainer | \ |
Container used to resolve
{@see \ |
| $translator | \ |
Translator instance or |
public function __construct(
?ContainerInterface $columnRenderersDependencyContainer = null,
?TranslatorInterface $translator = null,
) {
$this->filterFormId = Html::generateId();
$this->columnRendererContainer = new RendererContainer($columnRenderersDependencyContainer);
parent::__construct($translator);
}
Defined in:
Yiisoft\
Return a new instance that toggles automatically added accessibility attributes.
When enabled, rendering adds machine-readable accessibility attributes: scope="col" and aria-sort on
GridView header cells, scope="row" on row header cells, and aria-current, aria-disabled and
aria-label on pagination links (role="link" is also added to disabled pagination items, and aria-label
to the pagination nav container). Disabled by default.
| public static accessibility ( boolean $enabled = true ) | ||
| $enabled | boolean |
Whether to add accessibility attributes automatically. |
final public function accessibility(bool $enabled = true): static
{
$new = clone $this;
$new->accessibility = $enabled;
return $new;
}
Add configurations for a column renderers.
| public self addColumnRendererConfigs ( array $configs ) | ||
| $configs | array | |
| return | self |
New instance with the added column renderer configurations. |
|---|---|---|
public function addColumnRendererConfigs(array $configs): self
{
$new = clone $this;
$new->columnRendererContainer = $this->columnRendererContainer->addConfigs($configs);
return $new;
}
Defined in:
Yiisoft\
Adds one or more CSS classes to the existing container classes.
Multiple classes can be added by passing them as separate arguments. null values are filtered out
automatically.
| public static addContainerClass ( \ | ||
| $class | \ |
One or more CSS class names to add. Pass |
| return | Yiisoft\ |
A new instance with the specified CSS classes added to existing ones. |
|---|---|---|
public function addContainerClass(BackedEnum|string|null ...$class): static
{
$new = clone $this;
Html::addCssClass($new->containerAttributes, $class);
return $new;
}
| public static addHeaderClass ( \ | ||
| $class | \ |
|
public function addHeaderClass(BackedEnum|string|null ...$class): static
{
$new = clone $this;
Html::addCssClass($new->headerAttributes, $class);
return $new;
}
Add one or more CSS classes to the table tag.
| public self addTableClass ( string|null $class ) | ||
| $class | string|null |
One or many CSS classes. |
| return | self |
New instance with the added table CSS classes. |
|---|---|---|
public function addTableClass(?string ...$class): self
{
$new = clone $this;
Html::addCssClass($new->tableAttributes, $class);
return $new;
}
Add one or more CSS classes to the tbody tag.
| public self addTbodyClass ( string|null $class ) | ||
| $class | string|null |
One or many CSS classes. |
| return | self |
New instance with the added tbody CSS classes. |
|---|---|---|
public function addTbodyClass(?string ...$class): self
{
$new = clone $this;
Html::addCssClass($new->tbodyAttributes, $class);
return $new;
}
Returns a new instance with a callback that is executed once AFTER rendering each data row.
| public self afterRow ( Closure|null $callback ) | ||
| $callback | Closure|null |
The callback with the following signature:
The callback should return either:
|
| return | self |
New instance with the after row callback. |
|---|---|---|
public function afterRow(?Closure $callback): self
{
$new = clone $this;
$new->afterRowCallback = $callback;
return $new;
}
Defined in:
Yiisoft\
Returns a new instance with HTML content to be added before the closing container tag.
| public static append ( string|\ | ||
| $append | string|\ |
The HTML content to be appended. |
final public function append(string|Stringable ...$append): static
{
$new = clone $this;
$new->append = implode('', $append);
return $new;
}
Return a new instance with a callback that is executed BEFORE rendering each data row.
| public self beforeRow ( Closure|null $callback ) | ||
| $callback | Closure|null |
The callback with the following signature:
The callback should return either:
|
| return | self |
New instance with the before row callback. |
|---|---|---|
public function beforeRow(?Closure $callback): self
{
$new = clone $this;
$new->beforeRowCallback = $callback;
return $new;
}
Return new instance with the HTML attributes for the td tag.
| public self bodyCellAttributes ( array $attributes ) | ||
| $attributes | array |
The tag attributes in terms of name-value pairs. |
| return | self |
New instance with the body cell attributes. |
|---|---|---|
public function bodyCellAttributes(array $attributes): self
{
$new = clone $this;
$new->bodyCellAttributes = $attributes;
return $new;
}
Return new instance with the HTML attributes for body rows of the grid.
| public self bodyRowAttributes ( array|Closure $attributes ) | ||
| $attributes | array|Closure |
Attribute values indexed by attribute names or a callable that returns them. The signature of the callable should be:
If an array passed, the attribute values also can be a callable that returns them. The signature of the callable should be:
|
| return | self |
New instance with the body row attributes. |
|---|---|---|
public function bodyRowAttributes(Closure|array $attributes): self
{
$new = clone $this;
$new->bodyRowAttributes = $attributes;
return $new;
}
Return new instance with the content for the caption tag.
| public self caption ( string|\ | ||
| $content | string|\ |
Caption content. Set to |
| $attributes | array|null |
HTML attributes for the |
| return | self |
New instance with the caption content. |
|---|---|---|
public function caption(string|Stringable|null $content, ?array $attributes = null): self
{
$new = clone $this;
$new->caption = $content;
if ($attributes !== null) {
$new->captionAttributes = $attributes;
}
return $new;
}
Return new instance with the HTML attributes for the caption tag.
| public self captionAttributes ( array $attributes ) | ||
| $attributes | array |
The tag attributes in terms of name-value pairs. |
| return | self |
New instance with the caption attributes. |
|---|---|---|
public function captionAttributes(array $attributes): self
{
$new = clone $this;
$new->captionAttributes = $attributes;
return $new;
}
Returns a new instance with the column grouping enabled.
See also:
| public self columnGrouping ( boolean $enabled = true ) | ||
| $enabled | boolean |
Whether to enable the column grouping. |
| return | self |
New instance with the column grouping enabled. |
|---|---|---|
public function columnGrouping(bool $enabled = true): self
{
$new = clone $this;
$new->columnGrouping = $enabled;
return $new;
}
Return new instance with the specified column configurations.
| public self columns ( Yiisoft\ | ||
| $columns | Yiisoft\ |
The grid column configuration. Each element represents the configuration for one particular grid column. For example,
|
| return | self |
New instance with the column configurations. |
|---|---|---|
public function columns(ColumnInterface ...$columns): self
{
$new = clone $this;
$new->columns = $columns;
return $new;
}
Defined in:
Yiisoft\
Returns a new instance with the HTML attributes for container.
| public static containerAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
final public function containerAttributes(array $attributes): static
{
$new = clone $this;
$new->containerAttributes = $attributes;
return $new;
}
Defined in:
Yiisoft\
Set new container classes.
Multiple classes can be set by passing them as separate arguments. null values are filtered out
automatically.
| public static containerClass ( \ | ||
| $class | \ |
One or more CSS class names to use. Pass |
| return | Yiisoft\ |
A new instance with the specified CSS classes set. |
|---|---|---|
public function containerClass(BackedEnum|string|null ...$class): static
{
$new = clone $this;
$new->containerAttributes['class'] = [];
Html::addCssClass($new->containerAttributes, $class);
return $new;
}
| public static containerTag ( ?string $tag ) | ||
| $tag | ?string | |
final public function containerTag(?string $tag): static
{
if ($tag === '') {
throw new InvalidArgumentException('Tag name cannot be empty.');
}
$new = clone $this;
$new->containerTag = $tag;
return $new;
}
Defined in:
Yiisoft\
| public static dataReader ( \ | ||
| $dataReader | \ |
|
final public function dataReader(ReadableDataInterface $dataReader): static
{
$new = clone $this;
$new->dataReader = $dataReader;
return $new;
}
Return new instance with the HTML to display when the content is empty.
| public self emptyCell ( string $content, array|null $attributes = null ) | ||
| $content | string |
HTML content. Defaults to |
| $attributes | array|null |
The HTML attributes for the empty cell. Attribute values indexed by attribute names. |
| return | self |
New instance with the empty cell content. |
|---|---|---|
public function emptyCell(string $content, ?array $attributes = null): self
{
$new = clone $this;
$new->emptyCell = $content;
if ($attributes !== null) {
$new->emptyCellAttributes = $attributes;
}
return $new;
}
Returns a new instance with the HTML attributes for the empty cell.
| public self emptyCellAttributes ( array $attributes ) | ||
| $attributes | array |
The HTML attributes for the empty cell. Attribute values indexed by attribute names. |
| return | self |
New instance with the empty cell attributes. |
|---|---|---|
public function emptyCellAttributes(array $attributes): self
{
$new = clone $this;
$new->emptyCellAttributes = $attributes;
return $new;
}
Return new instance whether to show the header section of the grid.
| public self enableHeader ( boolean $enabled = true ) | ||
| $enabled | boolean |
Whether to show the header section of the grid. |
| return | self |
New instance with the header section visibility setting. |
|---|---|---|
public function enableHeader(bool $enabled = true): self
{
$new = clone $this;
$new->isHeaderEnabled = $enabled;
return $new;
}
| public static encodeHeader ( boolean $encode ) | ||
| $encode | boolean | |
final public function encodeHeader(bool $encode): static
{
$new = clone $this;
$new->encodeHeader = $encode;
return $new;
}
Return new instance with the HTML attributes for the filter cell (td) tag.
| public self filterCellAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
| return | self |
New instance with the filter cell attributes. |
|---|---|---|
public function filterCellAttributes(array $attributes): self
{
$new = clone $this;
$new->filterCellAttributes = $attributes;
return $new;
}
Return new instance with the CSS class to be added to filter cells that contain invalid values.
| public self filterCellInvalidClass ( string|null $class ) | ||
| $class | string|null |
The CSS class name. Set to null to remove the class. |
| return | self |
New instance with the filter cell invalid class. |
|---|---|---|
public function filterCellInvalidClass(?string $class): self
{
$new = clone $this;
$new->filterCellInvalidClass = $class;
return $new;
}
Return new instance with the HTML attributes for the filter errors container.
This container will be rendered below the filter cell when validation fails.
| public self filterErrorsContainerAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
| return | self |
New instance with the filter errors container attributes. |
|---|---|---|
public function filterErrorsContainerAttributes(array $attributes): self
{
$new = clone $this;
$new->filterErrorsContainerAttributes = $attributes;
return $new;
}
| public self filterFormAttributes ( array $attributes ) | ||
| $attributes | array | |
public function filterFormAttributes(array $attributes): self
{
$new = clone $this;
$new->filterFormAttributes = $attributes;
return $new;
}
| public self filterFormId ( string $id ) | ||
| $id | string | |
public function filterFormId(string $id): self
{
$new = clone $this;
$new->filterFormId = $id;
return $new;
}
Return new instance with the HTML attributes for the filter row.
| public self filterRowAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
| return | self |
New instance with the filter row attributes. |
|---|---|---|
public function filterRowAttributes(array $attributes): self
{
$new = clone $this;
$new->filterRowAttributes = $attributes;
return $new;
}
| protected \ |
final protected function getDataReader(): ReadableDataInterface
{
if ($this->dataReader === null) {
throw new DataReaderNotSetException();
}
return $this->dataReader;
}
| protected integer getDefaultPageSize ( ) |
final protected function getDefaultPageSize(): int
{
$dataReader = $this->getDataReader();
$pageSize = $dataReader instanceof PaginatorInterface
? $dataReader->getPageSize()
: PaginatorInterface::DEFAULT_PAGE_SIZE;
if (is_int($this->pageSizeConstraint)) {
return $pageSize <= $this->pageSizeConstraint
? $pageSize
: $this->pageSizeConstraint;
}
if (is_array($this->pageSizeConstraint)) {
return in_array($pageSize, $this->pageSizeConstraint, true)
? $pageSize
: $this->pageSizeConstraint[0];
}
return $pageSize;
}
| protected string getNoResultsContent ( ) |
final protected function getNoResultsContent(): string
{
$text = $this->translator->translate(
$this->noResultsText,
category: $this->translationCategory,
);
return str_replace('{text}', $text, $this->noResultsTemplate);
}
| protected ?bool getUseInlineJs ( ) |
final protected function getUseInlineJs(): ?bool
{
return $this->useInlineJs;
}
Defined in:
Yiisoft\
Return new instance with the header for the grid.
| public static header ( string $content ) | ||
| $content | string |
The header of the grid. {@see \ |
final public function header(string $content): static
{
$new = clone $this;
$new->header = $content;
return $new;
}
Defined in:
Yiisoft\
Return new instance with the HTML attributes for the header.
| public static headerAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
final public function headerAttributes(array $attributes): static
{
$new = clone $this;
$new->headerAttributes = $attributes;
return $new;
}
Return new instance with the HTML attributes for the th tag.
When accessibility attributes are enabled via {@see \scope="col". Pass ['scope' => null] to remove it, or another value to override it.
| public self headerCellAttributes ( array $attributes ) | ||
| $attributes | array |
The tag attributes in terms of name-value pairs. |
| return | self |
New instance with the header cell attributes. |
|---|---|---|
public function headerCellAttributes(array $attributes): self
{
$new = clone $this;
$new->headerCellAttributes = $attributes;
return $new;
}
Defined in:
Yiisoft\
| public static headerClass ( \ | ||
| $class | \ |
|
public function headerClass(BackedEnum|string|null ...$class): static
{
$new = clone $this;
$new->headerAttributes['class'] = [];
Html::addCssClass($new->headerAttributes, $class);
return $new;
}
Return new instance with the HTML attributes for the header row.
| public self headerRowAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
| return | self |
New instance with the header row attributes. |
|---|---|---|
public function headerRowAttributes(array $attributes): self
{
$new = clone $this;
$new->headerRowAttributes = $attributes;
return $new;
}
Defined in:
Yiisoft\
| public static headerTag ( ?string $tag ) | ||
| $tag | ?string | |
final public function headerTag(?string $tag): static
{
if ($tag === '') {
throw new InvalidArgumentException('Tag name cannot be empty.');
}
$new = clone $this;
$new->headerTag = $tag;
return $new;
}
Defined in:
Yiisoft\
Returns a new instance with the id of the grid view, detail view, or list view.
| public static id ( string $id ) | ||
| $id | string |
The ID of the grid view, detail view, or list view. |
final public function id(string $id): static
{
$new = clone $this;
$new->containerAttributes['id'] = $id;
return $new;
}
| public static ignoreMissingPage ( boolean $enabled ) | ||
| $enabled | boolean | |
final public function ignoreMissingPage(bool $enabled): static
{
$new = clone $this;
$new->ignoreMissingPage = $enabled;
return $new;
}
Returns a new instance with a flag defining whether an empty body cell keeps the HTML attributes set by its
column (grid-level {@see bodyCellAttributes()} and column-level bodyAttributes/bodyClass).
When enabled, {@see \
| public self keepColumnAttributesInEmptyCell ( boolean $enabled = true ) | ||
| $enabled | boolean |
Whether an empty body cell keeps the attributes set by its column. |
| return | self |
New instance with the flag applied. |
|---|---|---|
public function keepColumnAttributesInEmptyCell(bool $enabled = true): self
{
$new = clone $this;
$new->keepColumnAttributesInEmptyCell = $enabled;
return $new;
}
Whether to keep the current page when sorting is changed.
| public self keepPageOnSort ( boolean $enabled = true ) | ||
| $enabled | boolean |
Whether to keep the current page. |
| return | self |
New instance with the keep page on sort setting. |
|---|---|---|
public function keepPageOnSort(bool $enabled = true): self
{
$new = clone $this;
$new->keepPageOnSort = $enabled;
return $new;
}
Defined in:
Yiisoft\
Set configuration for keyset pagination widget.
| public static keysetPaginationConfig ( array $config ) | ||
| $config | array |
Widget config. |
final public function keysetPaginationConfig(array $config): static
{
$new = clone $this;
$new->keysetPaginationConfig = $config;
return $new;
}
Defined in:
Yiisoft\
Returns a new instance with the layout of the grid view, and list view.
| public static layout ( string $view ) | ||
| $view | string |
The template that determines how different sections of the grid view, list view. Should be organized. The following tokens will be replaced with the corresponding section contents:
|
final public function layout(string $view): static
{
$new = clone $this;
$new->layout = $view;
return $new;
}
| protected array makeFilters ( ) |
protected function makeFilters(): array
{
$columns = $this->getColumns();
$renderers = $this->getColumnRenderers();
$validationResult = new ValidationResult();
$context = new MakeFilterContext($validationResult, $this->urlParameterProvider);
$filters = [];
foreach ($columns as $i => $column) {
if ($renderers[$i] instanceof FilterableColumnRendererInterface) {
try {
$filter = $renderers[$i]->makeFilter($column, $context);
} catch (IncorrectValueException) {
$filters = null;
break;
}
if ($filter !== null) {
$filters[] = $filter;
}
}
}
return [$filters, $validationResult];
}
Defined in:
Yiisoft\
| public static multiSort ( boolean $enable = true ) | ||
| $enable | boolean | |
final public function multiSort(bool $enable = true): static
{
$new = clone $this;
$new->multiSort = $enable;
return $new;
}
| public self noResultsCellAttributes ( array $attributes ) | ||
| $attributes | array | |
public function noResultsCellAttributes(array $attributes): self
{
$new = clone $this;
$new->noResultsCellAttributes = $attributes;
return $new;
}
| public static noResultsTemplate ( string $template ) | ||
| $template | string | |
final public function noResultsTemplate(string $template): static
{
$new = clone $this;
$new->noResultsTemplate = $template;
return $new;
}
| public static noResultsText ( string $text ) | ||
| $text | string | |
final public function noResultsText(string $text): static
{
$new = clone $this;
$new->noResultsText = $text;
return $new;
}
Defined in:
Yiisoft\
Set configuration for offset pagination widget.
| public static offsetPaginationConfig ( array $config ) | ||
| $config | array |
Widget config. |
final public function offsetPaginationConfig(array $config): static
{
$new = clone $this;
$new->offsetPaginationConfig = $config;
return $new;
}
| public static pageNotFoundExceptionCallback ( ?callable $callback ) | ||
| $callback | ?callable | |
final public function pageNotFoundExceptionCallback(?callable $callback): static
{
$new = clone $this;
$new->pageNotFoundExceptionCallback = $callback;
return $new;
}
Defined in:
Yiisoft\
Return a new instance with the name of argument or query parameter for page.
| public static pageParameterName ( string $name ) | ||
| $name | string |
The name of argument or query parameter for page. |
final public function pageParameterName(string $name): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withPageParameterName($name);
return $new;
}
Defined in:
Yiisoft\
Creates a new instance with the specified page parameter type.
| public static pageParameterType ( \ | ||
| $type | \ |
The new page parameter type. |
| return | Yiisoft\ |
A new instance with the updated page parameter type. |
|---|---|---|
final public function pageParameterType(UrlParameterType $type): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withPageParameterType($type);
return $new;
}
Defined in:
Yiisoft\
Returns a new instance with the HTML attributes for page size wrapper tag.
| public static pageSizeAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
final public function pageSizeAttributes(array $attributes): static
{
$new = clone $this;
$new->pageSizeAttributes = $attributes;
return $new;
}
Defined in:
Yiisoft\
Get a new instance with a page size constraint set.
| public static pageSizeConstraint ( array|boolean|integer $pageSizeConstraint ) | ||
| $pageSizeConstraint | array|boolean|integer |
Page size constraint.
|
| return | Yiisoft\ |
New instance. |
|---|---|---|
final public function pageSizeConstraint(array|int|bool $pageSizeConstraint): static
{
$new = clone $this;
$new->pageSizeConstraint = $pageSizeConstraint;
return $new;
}
Defined in:
Yiisoft\
Return a new instance with the name of argument or query parameter for page size.
| public static pageSizeParameterName ( string $name ) | ||
| $name | string |
The name of argument or query parameter for page size. |
final public function pageSizeParameterName(string $name): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withPageSizeParameterName($name);
return $new;
}
Defined in:
Yiisoft\
Creates a new instance with the specified page size parameter type.
| public static pageSizeParameterType ( \ | ||
| $type | \ |
The new page size parameter type. |
| return | Yiisoft\ |
A new instance with the updated page size parameter type. |
|---|---|---|
final public function pageSizeParameterType(UrlParameterType $type): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withPageSizeParameterType($type);
return $new;
}
Defined in:
Yiisoft\
| public static pageSizeTag ( ?string $tag ) | ||
| $tag | ?string | |
final public function pageSizeTag(?string $tag): static
{
if ($tag === '') {
throw new InvalidArgumentException('Tag name cannot be empty.');
}
$new = clone $this;
$new->pageSizeTag = $tag;
return $new;
}
Defined in:
Yiisoft\
Returns a new instance with the page size template.
| public static pageSizeTemplate ( string|null $template ) | ||
| $template | string|null |
The HTML content to be displayed as the page size control. If you don't want to show
control, you may set it with an empty string or The following tokens will be replaced with the corresponding values:
|
final public function pageSizeTemplate(?string $template): static
{
$new = clone $this;
$new->pageSizeTemplate = $template;
return $new;
}
| public static pageSizeWidget ( ?\ | ||
| $widget | ?\ |
|
final public function pageSizeWidget(?PageSizeWidgetInterface $widget): static
{
$new = clone $this;
$new->pageSizeWidget = $widget;
return $new;
}
| public static paginationWidget ( ?\ | ||
| $widget | ?\ |
|
final public function paginationWidget(?PaginationWidgetInterface $widget): static
{
$new = clone $this;
$new->paginationWidget = $widget;
return $new;
}
Defined in:
Yiisoft\
Prepares data reader using current URL parameters, filters, and sorting.
Returns null when filter values are invalid and the data reader can't be prepared for the current filter.
With pagination enabled, the current page is read to validate it and apply missing-page handling.
Pass false to prepare data for exports: filters and sorting will be applied, but pagination URL parameters
won't be used and the data reader won't be wrapped into a paginator. The configured data reader must not
implement {@see \
| public ?\ | ||
| $withPagination | boolean | |
| throws | LogicException |
If pagination is disabled and the configured data reader is a paginator. |
|---|---|---|
| throws | \ |
|
final public function prepareDataReader(bool $withPagination = true): ?ReadableDataInterface
{
if (!$withPagination && $this->getDataReader() instanceof PaginatorInterface) {
throw new LogicException(
'Cannot prepare a data reader without pagination because the configured data reader is a paginator.',
);
}
[$filters] = $this->makeFilters();
if ($filters === null) {
return null;
}
if ($withPagination) {
// Items are read (and discarded) here so an out-of-range page is detected and handled
// via `ignoreMissingPage`/`pageNotFoundExceptionCallback`, instead of surfacing later
// when the caller reads the returned data reader.
[$dataReader] = $this->prepareDataReaderAndItems($filters);
return $dataReader;
}
$sort = $this->urlParameterProvider->get(
$this->urlConfig->getSortParameterName(),
$this->urlConfig->getSortParameterType(),
);
return $this->prepareDataReaderByParams(null, $sort, $filters);
}
| protected array prepareOrder ( array $order ) | ||
| $order | array | |
protected function prepareOrder(array $order): array
{
$columns = $this->getColumns();
$renderers = $this->getColumnRenderers();
$allowedProperties = [];
foreach ($columns as $i => $column) {
if ($renderers[$i] instanceof SortableColumnRendererInterface) {
$allowedProperties[] = $renderers[$i]->getOrderProperties($column);
}
}
$allowedProperties = array_merge(...$allowedProperties);
return array_filter(
$order,
static fn(string $property): bool => in_array($property, $allowedProperties, true),
ARRAY_FILTER_USE_KEY,
);
}
Defined in:
Yiisoft\
Returns a new instance with HTML content to be added after the opening container tag.
| public static prepend ( string|\ | ||
| $prepend | string|\ |
The HTML content to be prepended. |
final public function prepend(string|Stringable ...$prepend): static
{
$new = clone $this;
$new->prepend = implode('', $prepend);
return $new;
}
| public static previousPageParameterName ( string $name ) | ||
| $name | string | |
final public function previousPageParameterName(string $name): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withPreviousPageParameterName($name);
return $new;
}
Defined in:
Yiisoft\
Creates a new instance with the specified previous page parameter type.
| public static previousPageParameterType ( \ | ||
| $type | \ |
The new previous page parameter type. |
| return | Yiisoft\ |
A new instance with the updated previous page parameter type. |
|---|---|---|
final public function previousPageParameterType(UrlParameterType $type): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withPreviousPageParameterType($type);
return $new;
}
Defined in:
Yiisoft\
| public string render ( ) |
final public function render(): string
{
[$filters, $filterValidationResult] = $this->makeFilters();
[$preparedDataReader, $items] = $filters === null
? [null, []]
: $this->prepareDataReaderAndItems($filters);
$content = trim(
strtr(
$this->layout,
[
'{header}' => $this->renderHeader(),
'{toolbar}' => $this->toolbar,
'{items}' => $this->renderItems($items, $filterValidationResult, $preparedDataReader),
'{summary}' => $this->renderSummary($preparedDataReader),
'{pager}' => $this->renderPagination($preparedDataReader),
'{pageSize}' => $this->renderPageSize($preparedDataReader),
],
),
);
if ($this->prepend !== '') {
$content = $this->prepend . "\n" . $content;
}
if ($this->append !== '') {
$content .= "\n" . $this->append;
}
return $this->containerTag === null
? $content
: Html::tag($this->containerTag, "\n" . $content . "\n" , $this->containerAttributes)
->encode(false)
->render();
}
| protected string renderItems ( array $items, \ | ||
| $items | array | |
| $filterValidationResult | \ |
|
| $preparedDataReader | ?\ |
|
protected function renderItems(
array $items,
ValidationResult $filterValidationResult,
?ReadableDataInterface $preparedDataReader,
): string {
$columns = $this->getColumns();
$renderers = $this->getColumnRenderers();
$blocks = [];
$filtersForm = '';
$dataReader = $this->getDataReader();
if ($preparedDataReader instanceof PaginatorInterface) {
$pageToken = $preparedDataReader->isOnFirstPage() ? null : $preparedDataReader->getToken();
$pageSize = $preparedDataReader->getPageSize();
if ($pageSize === $this->getDefaultPageSize()) {
$pageSize = null;
}
} else {
$pageToken = null;
$pageSize = null;
}
$globalContext = new GlobalContext(
$this->getSort($dataReader),
$this->getSort($preparedDataReader),
$this->getAllowedPropertiesForSort(),
$this->sortableHeaderClass,
$this->sortableHeaderPrepend,
$this->sortableHeaderAppend,
$this->sortableHeaderAscClass,
$this->sortableHeaderAscPrepend,
$this->sortableHeaderAscAppend,
$this->sortableHeaderDescClass,
$this->sortableHeaderDescPrepend,
$this->sortableHeaderDescAppend,
$this->sortableLinkAttributes,
$this->sortableLinkAscClass,
$this->sortableLinkDescClass,
$this->keepPageOnSort ? $pageToken : null,
$pageSize,
$this->multiSort,
$this->urlConfig,
$this->urlCreator,
$this->translator,
$this->translationCategory,
$this->accessibility,
);
$tags = [];
$hasFilters = false;
$filterContext = new FilterContext(
formId: $this->filterFormId,
validationResult: $filterValidationResult,
cellInvalidClass: $this->filterCellInvalidClass,
errorsContainerAttributes: $this->filterErrorsContainerAttributes,
urlParameterProvider: $this->urlParameterProvider,
useInlineJs: $this->getUseInlineJs(),
);
foreach ($columns as $i => $column) {
$cell = $renderers[$i] instanceof FilterableColumnRendererInterface
? $renderers[$i]->renderFilter($column, new Cell(attributes: $this->filterCellAttributes), $filterContext)
: null;
if ($cell === null) {
$tags[] = Html::td(' ')->encode(false);
} else {
$tags[] = Html::td(attributes: $cell->getAttributes())
->content(...$cell->getContent())
->encode($cell->shouldEncode())
->doubleEncode($cell->shouldDoubleEncode());
$hasFilters = true;
}
}
if ($hasFilters) {
$sort = $this->urlParameterProvider->get(
$this->urlConfig->getSortParameterName(),
$this->urlConfig->getSortParameterType(),
);
$url = $this->urlCreator === null ? '' : call_user_func_array(
$this->urlCreator,
UrlParametersFactory::create(
null,
$this->urlConfig->getPageSizeParameterType() === UrlParameterType::Path ? $pageSize : null,
$this->urlConfig->getSortParameterType() === UrlParameterType::Path ? $sort : null,
$this->urlConfig,
),
);
$content = [Html::submitButton()];
if (!empty($pageSize) && $this->urlConfig->getPageSizeParameterType() === UrlParameterType::Query) {
$content[] = Html::hiddenInput($this->urlConfig->getPageSizeParameterName(), $pageSize);
}
if (!empty($sort) && $this->urlConfig->getSortParameterType() === UrlParameterType::Query) {
$content[] = Html::hiddenInput($this->urlConfig->getSortParameterName(), $sort);
}
$formAttributes = $this->filterFormAttributes;
$formAttributes['id'] = $filterContext->formId;
Html::addCssStyle($formAttributes, 'display:none');
$filtersForm = Html::form($url, 'GET', $formAttributes)
->content(...$content)
->render();
$filterRow = Html::tr($this->filterRowAttributes)->cells(...$tags);
} else {
$filterRow = null;
}
if ($this->columnGrouping) {
$tags = [];
foreach ($columns as $i => $column) {
$cell = $renderers[$i]->renderColumn($column, new Cell(), $globalContext);
$tags[] = Html::col($cell->getAttributes());
}
$blocks[] = Html::colgroup()->columns(...$tags)->render();
}
if ($this->isHeaderEnabled) {
$tags = [];
foreach ($columns as $i => $column) {
$headerCell = new Cell($this->headerCellAttributes);
/**
* @psalm-suppress PossiblyNullReference The `??` operator puts its left operand into isset context,
* so Psalm treats `$renderers[$i]` as possibly null.
*/
$cell = $renderers[$i]->renderHeader($column, $headerCell, $globalContext) ?? $headerCell;
$cellAttributes = $this->addScopeAttribute($cell->getAttributes(), 'col');
$tags[] = $cell->isEmptyContent()
? Html::th(' ', $cellAttributes)->encode(false)
: Html::th(attributes: $cellAttributes)
->content(...$cell->getContent())
->encode($cell->shouldEncode())
->doubleEncode($cell->shouldDoubleEncode());
}
$headerRow = Html::tr($this->headerRowAttributes)->cells(...$tags);
$thead = Html::thead()->rows($headerRow);
if ($filterRow !== null) {
$thead = $thead->addRows($filterRow);
}
$blocks[] = $thead->render();
}
if ($this->isFooterEnabled) {
$tags = [];
foreach ($columns as $i => $column) {
$cell = $renderers[$i]->renderFooter(
$column,
(new Cell())->content(' ')->encode(false),
$globalContext,
);
$tags[] = Html::td(attributes: $cell->getAttributes())
->content(...$cell->getContent())
->encode($cell->shouldEncode())
->doubleEncode($cell->shouldDoubleEncode());
}
$footerRow = Html::tr($this->footerRowAttributes)->cells(...$tags);
$blocks[] = Html::tfoot()->rows($footerRow)->render();
}
$rows = [];
$index = 0;
foreach ($items as $key => $value) {
if ($this->beforeRowCallback !== null) {
/**
* @psalm-suppress InvalidArgument
*/
$row = ($this->beforeRowCallback)($value, $key, $index, $this);
if (!empty($row)) {
$rows[] = $row;
}
}
$tags = [];
foreach ($columns as $i => $column) {
$context = new DataContext($preparedDataReader, $column, $value, $key, $index);
$cell = $renderers[$i]->renderBody($column, new Cell($this->bodyCellAttributes), $context);
if ($cell->isEmptyContent()) {
$cellAttributes = $this->prepareEmptyBodyCellAttributes($cell->getAttributes(), $context);
$tag = $cell->isRowHeader()
? Html::th($this->emptyCell, $this->addScopeAttribute($cellAttributes, 'row'))
: Html::td($this->emptyCell, $cellAttributes);
$tags[] = $tag->encode(false);
} else {
$cellAttributes = $this->prepareBodyCellAttributes($cell->getAttributes(), $context);
$tag = $cell->isRowHeader()
? Html::th(attributes: $this->addScopeAttribute($cellAttributes, 'row'))
: Html::td(attributes: $cellAttributes);
$tags[] = $tag
->content(...$cell->getContent())
->encode($cell->shouldEncode())
->doubleEncode($cell->shouldDoubleEncode());
}
}
$bodyRowAttributes = $this->prepareBodyRowAttributes(
$this->bodyRowAttributes,
new BodyRowContext($value, $key, $index),
);
$rows[] = Html::tr($bodyRowAttributes)->cells(...$tags);
if ($this->afterRowCallback !== null) {
/**
* @psalm-suppress InvalidArgument
*/
$row = ($this->afterRowCallback)($value, $key, $index, $this);
if (!empty($row)) {
$rows[] = $row;
}
}
$index++;
}
$blocks[] = empty($rows)
? Html::tbody($this->tbodyAttributes)
->rows(Html::tr()->cells($this->renderEmptyCell(count($columns))))
->render()
: Html::tbody($this->tbodyAttributes)->rows(...$rows)->render();
$caption = $this->caption === null
? ''
: Html::tag('caption', $this->caption, $this->captionAttributes) . "\n" ;
return
$filtersForm
. Html::tag('table', attributes: $this->tableAttributes)->open()
. "\n"
. $caption
. implode("\n" , $blocks)
. "\n"
. '</table>';
}
Defined in:
Yiisoft\
Creates a new instance with the specified sort parameter name.
| public static sortParameterName ( string $name ) | ||
| $name | string |
The new sort parameter name. |
| return | Yiisoft\ |
A new instance with the updated sort parameter name. |
|---|---|---|
final public function sortParameterName(string $name): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withSortParameterName($name);
return $new;
}
Defined in:
Yiisoft\
Creates a new instance with the specified sort parameter type.
| public static sortParameterType ( \ | ||
| $type | \ |
The new sort parameter type. |
| return | Yiisoft\ |
A new instance with the updated sort parameter type. |
|---|---|---|
final public function sortParameterType(UrlParameterType $type): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withSortParameterType($type);
return $new;
}
Return new instance with the content to be appended to sortable column headers.
| public self sortableHeaderAppend ( string|\ | ||
| $content | string|\ |
The content to append. |
| return | self |
New instance with the sortable header append content. |
|---|---|---|
public function sortableHeaderAppend(string|Stringable $content): self
{
$new = clone $this;
$new->sortableHeaderAppend = $content;
return $new;
}
Return new instance with the content to be appended to ascending sorted column headers.
| public self sortableHeaderAscAppend ( string|\ | ||
| $content | string|\ |
The content to append. |
| return | self |
New instance with the sortable header ascending append content. |
|---|---|---|
public function sortableHeaderAscAppend(string|Stringable $content): self
{
$new = clone $this;
$new->sortableHeaderAscAppend = $content;
return $new;
}
Return new instance with the CSS class for ascending sorted column headers.
| public self sortableHeaderAscClass ( string|null $class ) | ||
| $class | string|null |
The CSS class name. Set to |
| return | self |
New instance with the ascending sorted header class. |
|---|---|---|
public function sortableHeaderAscClass(?string $class): self
{
$new = clone $this;
$new->sortableHeaderAscClass = $class;
return $new;
}
Return new instance with the content to be prepended to ascending sorted column headers.
| public self sortableHeaderAscPrepend ( string|\ | ||
| $content | string|\ |
The content to prepend. |
| return | self |
New instance with the sortable header ascending prepend content. |
|---|---|---|
public function sortableHeaderAscPrepend(string|Stringable $content): self
{
$new = clone $this;
$new->sortableHeaderAscPrepend = $content;
return $new;
}
Return new instance with the CSS class for sortable column headers that are not currently sorted.
| public self sortableHeaderClass ( string|null $class ) | ||
| $class | string|null |
The CSS class name. Set to |
| return | self |
New instance with the sortable header class. |
|---|---|---|
public function sortableHeaderClass(?string $class): self
{
$new = clone $this;
$new->sortableHeaderClass = $class;
return $new;
}
Return new instance with the content to be appended to descending sorted column headers.
| public self sortableHeaderDescAppend ( string|\ | ||
| $content | string|\ |
The content to append. |
| return | self |
New instance with the sortable header descending append content. |
|---|---|---|
public function sortableHeaderDescAppend(string|Stringable $content): self
{
$new = clone $this;
$new->sortableHeaderDescAppend = $content;
return $new;
}
Return new instance with the CSS class for descending sorted column headers.
| public self sortableHeaderDescClass ( string|null $class ) | ||
| $class | string|null |
The CSS class name. Set to |
| return | self |
New instance with the descending sorted header class. |
|---|---|---|
public function sortableHeaderDescClass(?string $class): self
{
$new = clone $this;
$new->sortableHeaderDescClass = $class;
return $new;
}
Return new instance with the content to be prepended to descending sorted column headers.
| public self sortableHeaderDescPrepend ( string|\ | ||
| $content | string|\ |
The content to prepend. |
| return | self |
New instance with the sortable header descending prepend content. |
|---|---|---|
public function sortableHeaderDescPrepend(string|Stringable $content): self
{
$new = clone $this;
$new->sortableHeaderDescPrepend = $content;
return $new;
}
Return new instance with the content to be prepended to sortable column headers.
| public self sortableHeaderPrepend ( string|\ | ||
| $content | string|\ |
The content to prepend. |
| return | self |
New instance with the sortable header prepend content. |
|---|---|---|
public function sortableHeaderPrepend(string|Stringable $content): self
{
$new = clone $this;
$new->sortableHeaderPrepend = $content;
return $new;
}
Return new instance with the CSS class for links in ascending sorted column headers.
| public self sortableLinkAscClass ( string|null $class ) | ||
| $class | string|null |
The CSS class name. Set to |
| return | self |
New instance with the ascending sort link class. |
|---|---|---|
public function sortableLinkAscClass(?string $class): self
{
$new = clone $this;
$new->sortableLinkAscClass = $class;
return $new;
}
Return new instance with the HTML attributes for a link in sortable columns' headers.
| public self sortableLinkAttributes ( array $attributes ) | ||
| $attributes | array |
The tag attributes in terms of name-value pairs. |
| return | self |
New instance with the sortable link attributes. |
|---|---|---|
public function sortableLinkAttributes(array $attributes): self
{
$new = clone $this;
$new->sortableLinkAttributes = $attributes;
return $new;
}
Return new instance with the CSS class for links in descending sorted column headers.
| public self sortableLinkDescClass ( string|null $class ) | ||
| $class | string|null |
The CSS class name. Set to |
| return | self |
New instance with the descending sort link class. |
|---|---|---|
public function sortableLinkDescClass(?string $class): self
{
$new = clone $this;
$new->sortableLinkDescClass = $class;
return $new;
}
Defined in:
Yiisoft\
Returns a new instance with the HTML attributes for summary wrapper tag.
| public static summaryAttributes ( array $attributes ) | ||
| $attributes | array |
Attribute values indexed by attribute names. |
final public function summaryAttributes(array $attributes): static
{
$new = clone $this;
$new->summaryAttributes = $attributes;
return $new;
}
Defined in:
Yiisoft\
| public static summaryTag ( ?string $tag ) | ||
| $tag | ?string | |
final public function summaryTag(?string $tag): static
{
if ($tag === '') {
throw new InvalidArgumentException('Tag name cannot be empty.');
}
$new = clone $this;
$new->summaryTag = $tag;
return $new;
}
Defined in:
Yiisoft\
Returns a new instance with the summary template.
| public static summaryTemplate ( string|null $template ) | ||
| $template | string|null |
The HTML content to be displayed as the summary. If you don't want to show the summary, you may set it with an empty string or null. The following tokens will be replaced with the corresponding values:
|
final public function summaryTemplate(?string $template): static
{
$new = clone $this;
$new->summaryTemplate = $template;
return $new;
}
Return new instance with the HTML attributes for the table tag.
| public self tableAttributes ( array $attributes ) | ||
| $attributes | array |
The tag attributes in terms of name-value pairs. |
| return | self |
New instance with the table attributes. |
|---|---|---|
public function tableAttributes(array $attributes): self
{
$new = clone $this;
$new->tableAttributes = $attributes;
return $new;
}
Replace current table tag CSS classes with a new set of classes.
| public self tableClass ( string|null $class ) | ||
| $class | string|null |
One or many CSS classes. |
| return | self |
New instance with the replaced table CSS classes. |
|---|---|---|
public function tableClass(?string ...$class): self
{
$new = clone $this;
$new->tableAttributes['class'] = array_filter($class, static fn($c) => $c !== null);
return $new;
}
Return new instance with the HTML attributes for the tbody tag.
| public self tbodyAttributes ( array $attributes ) | ||
| $attributes | array |
The tag attributes in terms of name-value pairs. |
| return | self |
New instance with the tbody attributes. |
|---|---|---|
public function tbodyAttributes(array $attributes): self
{
$new = clone $this;
$new->tbodyAttributes = $attributes;
return $new;
}
Replace current tbody tag CSS classes with a new set of classes.
| public self tbodyClass ( string|null $class ) | ||
| $class | string|null |
One or many CSS classes. |
| return | self |
New instance with the replaced tbody CSS classes. |
|---|---|---|
public function tbodyClass(?string ...$class): self
{
$new = clone $this;
$new->tbodyAttributes['class'] = array_filter($class, static fn($c) => $c !== null);
return $new;
}
Defined in:
Yiisoft\
Return new instance with toolbar content.
| public static toolbar ( string $content ) | ||
| $content | string |
The toolbar content. |
final public function toolbar(string $content): static
{
$new = clone $this;
$new->toolbar = $content;
return $new;
}
Defined in:
Yiisoft\
Return a new instance with arguments of the route.
| public static urlArguments ( array $arguments ) | ||
| $arguments | array |
Arguments of the route. |
final public function urlArguments(array $arguments): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withArguments($arguments);
return $new;
}
Defined in:
Yiisoft\
| public static urlCreator ( ?callable $urlCreator ) | ||
| $urlCreator | ?callable | |
final public function urlCreator(?callable $urlCreator): static
{
$new = clone $this;
$new->urlCreator = $urlCreator;
return $new;
}
| public static urlParameterProvider ( Yiisoft\ | ||
| $provider | Yiisoft\ |
|
final public function urlParameterProvider(UrlParameterProviderInterface $provider): static
{
$new = clone $this;
$new->urlParameterProvider = $provider;
return $new;
}
Defined in:
Yiisoft\
Return a new instance with query parameters of the route.
| public static urlQueryParameters ( array $parameters ) | ||
| $parameters | array |
The query parameters of the route. |
final public function urlQueryParameters(array $parameters): static
{
$new = clone $this;
$new->urlConfig = $this->urlConfig->withQueryParameters($parameters);
return $new;
}
Defined in:
Yiisoft\
Return a new instance forcing inline JavaScript for every rendered {@see UseInlineJsInterface} widget.
| public static useInlineJs ( boolean|null $enabled ) | ||
| $enabled | boolean|null |
|
final public function useInlineJs(?bool $enabled): static
{
$new = clone $this;
$new->useInlineJs = $enabled;
return $new;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.