0 follower

Final Class Yiisoft\Yii\DataView\GridView\GridView

InheritanceYiisoft\Yii\DataView\GridView\GridView » Yiisoft\Yii\DataView\BaseListView » Yiisoft\Widget\Widget

The GridView widget displays data in a grid.

You can configure the columns of the grid table in terms of {@see \Yiisoft\Yii\DataView\GridView\Column} classes configured via {@see \Yiisoft\Yii\DataView\GridView\columns}.

The look and feel of a grid view can be customized using many properties.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Yii\DataView\GridView\GridView
addColumnRendererConfigs() Add configurations for a column renderers. Yiisoft\Yii\DataView\GridView\GridView
addContainerClass() Adds one or more CSS classes to the existing container classes. Yiisoft\Yii\DataView\BaseListView
addHeaderClass() Yiisoft\Yii\DataView\BaseListView
addTableClass() Add one or more CSS classes to the table tag. Yiisoft\Yii\DataView\GridView\GridView
addTbodyClass() Add one or more CSS classes to the tbody tag. Yiisoft\Yii\DataView\GridView\GridView
afterRow() Returns a new instance with a callback that is executed once AFTER rendering each data row. Yiisoft\Yii\DataView\GridView\GridView
append() Returns a new instance with HTML content to be added before the closing container tag. Yiisoft\Yii\DataView\BaseListView
beforeRow() Return a new instance with a callback that is executed BEFORE rendering each data row. Yiisoft\Yii\DataView\GridView\GridView
bodyCellAttributes() Return new instance with the HTML attributes for the td tag. Yiisoft\Yii\DataView\GridView\GridView
bodyRowAttributes() Return new instance with the HTML attributes for body rows of the grid. Yiisoft\Yii\DataView\GridView\GridView
columnGrouping() Returns a new instance with the column grouping enabled. Yiisoft\Yii\DataView\GridView\GridView
columns() Return new instance with the specified column configurations. Yiisoft\Yii\DataView\GridView\GridView
containerAttributes() Returns a new instance with the HTML attributes for container. Yiisoft\Yii\DataView\BaseListView
containerClass() Set new container classes. Yiisoft\Yii\DataView\BaseListView
containerTag() Yiisoft\Yii\DataView\BaseListView
dataReader() Yiisoft\Yii\DataView\BaseListView
emptyCell() Return new instance with the HTML to display when the content is empty. Yiisoft\Yii\DataView\GridView\GridView
emptyCellAttributes() Returns a new instance with the HTML attributes for the empty cell. Yiisoft\Yii\DataView\GridView\GridView
enableFooter() Whether to show the footer section of the grid. Yiisoft\Yii\DataView\GridView\GridView
enableHeader() Return new instance whether to show the header section of the grid. Yiisoft\Yii\DataView\GridView\GridView
encodeHeader() Yiisoft\Yii\DataView\BaseListView
filterCellAttributes() Return new instance with the HTML attributes for the filter cell (td) tag. Yiisoft\Yii\DataView\GridView\GridView
filterCellInvalidClass() Return new instance with the CSS class to be added to filter cells that contain invalid values. Yiisoft\Yii\DataView\GridView\GridView
filterErrorsContainerAttributes() Return new instance with the HTML attributes for the filter errors container. Yiisoft\Yii\DataView\GridView\GridView
filterFormAttributes() Yiisoft\Yii\DataView\GridView\GridView
filterFormId() Yiisoft\Yii\DataView\GridView\GridView
footerRowAttributes() Returns a new instance with the HTML attributes for footer row. Yiisoft\Yii\DataView\GridView\GridView
header() Return new instance with the header for the grid. Yiisoft\Yii\DataView\BaseListView
headerAttributes() Return new instance with the HTML attributes for the header. Yiisoft\Yii\DataView\BaseListView
headerCellAttributes() Return new instance with the HTML attributes for the th tag. Yiisoft\Yii\DataView\GridView\GridView
headerClass() Yiisoft\Yii\DataView\BaseListView
headerRowAttributes() Return new instance with the HTML attributes for the header row. Yiisoft\Yii\DataView\GridView\GridView
headerTag() Yiisoft\Yii\DataView\BaseListView
id() Returns a new instance with the id of the grid view, detail view, or list view. Yiisoft\Yii\DataView\BaseListView
ignoreMissingPage() Yiisoft\Yii\DataView\BaseListView
keepPageOnSort() Whether to keep the current page when sorting is changed. Yiisoft\Yii\DataView\GridView\GridView
keysetPaginationConfig() Set configuration for keyset pagination widget. Yiisoft\Yii\DataView\BaseListView
layout() Returns a new instance with the layout of the grid view, and list view. Yiisoft\Yii\DataView\BaseListView
multiSort() Yiisoft\Yii\DataView\BaseListView
noResultsCellAttributes() Yiisoft\Yii\DataView\GridView\GridView
noResultsTemplate() Yiisoft\Yii\DataView\BaseListView
noResultsText() Yiisoft\Yii\DataView\BaseListView
offsetPaginationConfig() Set configuration for offset pagination widget. Yiisoft\Yii\DataView\BaseListView
pageNotFoundExceptionCallback() Yiisoft\Yii\DataView\BaseListView
pageParameterName() Return a new instance with the name of argument or query parameter for page. Yiisoft\Yii\DataView\BaseListView
pageParameterType() Creates a new instance with the specified page parameter type. Yiisoft\Yii\DataView\BaseListView
pageSizeAttributes() Returns a new instance with the HTML attributes for page size wrapper tag. Yiisoft\Yii\DataView\BaseListView
pageSizeConstraint() Get a new instance with a page size constraint set. Yiisoft\Yii\DataView\BaseListView
pageSizeParameterName() Return a new instance with the name of argument or query parameter for page size. Yiisoft\Yii\DataView\BaseListView
pageSizeParameterType() Creates a new instance with the specified page size parameter type. Yiisoft\Yii\DataView\BaseListView
pageSizeTag() Yiisoft\Yii\DataView\BaseListView
pageSizeTemplate() Returns a new instance with the page size template. Yiisoft\Yii\DataView\BaseListView
pageSizeWidget() Yiisoft\Yii\DataView\BaseListView
paginationWidget() Yiisoft\Yii\DataView\BaseListView
prepend() Returns a new instance with HTML content to be added after the opening container tag. Yiisoft\Yii\DataView\BaseListView
previousPageParameterName() Yiisoft\Yii\DataView\BaseListView
previousPageParameterType() Creates a new instance with the specified previous page parameter type. Yiisoft\Yii\DataView\BaseListView
render() Yiisoft\Yii\DataView\BaseListView
sortParameterName() Creates a new instance with the specified sort parameter name. Yiisoft\Yii\DataView\BaseListView
sortParameterType() Creates a new instance with the specified sort parameter type. Yiisoft\Yii\DataView\BaseListView
sortableHeaderAppend() Return new instance with the content to be appended to sortable column headers. Yiisoft\Yii\DataView\GridView\GridView
sortableHeaderAscAppend() Return new instance with the content to be appended to ascending sorted column headers. Yiisoft\Yii\DataView\GridView\GridView
sortableHeaderAscPrepend() Return new instance with the content to be prepended to ascending sorted column headers. Yiisoft\Yii\DataView\GridView\GridView
sortableHeaderDescAppend() Return new instance with the content to be appended to descending sorted column headers. Yiisoft\Yii\DataView\GridView\GridView
sortableHeaderDescPrepend() Return new instance with the content to be prepended to descending sorted column headers. Yiisoft\Yii\DataView\GridView\GridView
sortableHeaderPrepend() Return new instance with the content to be prepended to sortable column headers. Yiisoft\Yii\DataView\GridView\GridView
sortableLinkAttributes() Return new instance with the HTML attributes for a link in sortable columns' headers. Yiisoft\Yii\DataView\GridView\GridView
summaryAttributes() Returns a new instance with the HTML attributes for summary wrapper tag. Yiisoft\Yii\DataView\BaseListView
summaryTag() Yiisoft\Yii\DataView\BaseListView
summaryTemplate() Returns a new instance with the summary template. Yiisoft\Yii\DataView\BaseListView
tableAttributes() Return new instance with the HTML attributes for the table tag. Yiisoft\Yii\DataView\GridView\GridView
tableClass() Replace current table tag CSS classes with a new set of classes. Yiisoft\Yii\DataView\GridView\GridView
tbodyAttributes() Return new instance with the HTML attributes for the tbody tag. Yiisoft\Yii\DataView\GridView\GridView
tbodyClass() Replace current tbody tag CSS classes with a new set of classes. Yiisoft\Yii\DataView\GridView\GridView
toolbar() Return new instance with toolbar content. Yiisoft\Yii\DataView\BaseListView
urlArguments() Return a new instance with arguments of the route. Yiisoft\Yii\DataView\BaseListView
urlCreator() Yiisoft\Yii\DataView\BaseListView
urlParameterProvider() Yiisoft\Yii\DataView\BaseListView
urlQueryParameters() Return a new instance with query parameters of the route. Yiisoft\Yii\DataView\BaseListView

Constants

Hide inherited constants

Constant Value Description Defined By
DEFAULT_TRANSLATION_CATEGORY 'yii-dataview' A name for {@see CategorySource} used with translator ({@see TranslatorInterface}) by default. Yiisoft\Yii\DataView\BaseListView

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Psr\Container\ContainerInterface $columnRenderersDependencyContainer, \Yiisoft\Translator\TranslatorInterface|null $translator null )
$columnRenderersDependencyContainer \Psr\Container\ContainerInterface

Container used to resolve {@see \Yiisoft\Yii\DataView\GridView\Column\ColumnRendererInterface column renderer} dependencies.

$translator \Yiisoft\Translator\TranslatorInterface|null

Translator instance or null if no translation is needed.

                public function __construct(
    ContainerInterface $columnRenderersDependencyContainer,
    ?TranslatorInterface $translator = null,
) {
    $this->filterFormId = Html::generateId();
    $this->columnRendererContainer = new RendererContainer($columnRenderersDependencyContainer);
    parent::__construct($translator);
}

            
addColumnRendererConfigs() public method

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;
}

            
addContainerClass() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::addContainerClass()

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 Yiisoft\Yii\DataView\GridView\GridView addContainerClass ( \BackedEnum|string|null $class )
$class \BackedEnum|string|null

One or more CSS class names to add. Pass null to skip adding a class.

return Yiisoft\Yii\DataView\GridView\GridView

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;
}

            
addHeaderClass() public method
public Yiisoft\Yii\DataView\GridView\GridView addHeaderClass ( \BackedEnum|string|null $class )
$class \BackedEnum|string|null

                public function addHeaderClass(BackedEnum|string|null ...$class): static
{
    $new = clone $this;
    Html::addCssClass($new->headerAttributes, $class);
    return $new;
}

            
addTableClass() public method

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;
}

            
addTbodyClass() public method

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;
}

            
afterRow() public method

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:

function (array|object $data, array|int|string $key, int $index, GridView $grid): ?Tr
  • $data: the data model being rendered
  • $key: the key associated with the data model
  • $index: the zero-based index of the data model in the model array
  • $grid: the GridView object

The callback should return either:

  • a {@see \Yiisoft\Html\Tag\Tr} instance representing a table row to be rendered after the data row
  • or null if no additional row should be rendered
return self

New instance with the after row callback.

                public function afterRow(?Closure $callback): self
{
    $new = clone $this;
    $new->afterRowCallback = $callback;
    return $new;
}

            
append() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::append()

Returns a new instance with HTML content to be added before the closing container tag.

public Yiisoft\Yii\DataView\GridView\GridView append ( string|\Stringable $append )
$append string|\Stringable

The HTML content to be appended.

                final public function append(string|Stringable ...$append): static
{
    $new = clone $this;
    $new->append = implode('', $append);
    return $new;
}

            
beforeRow() public method

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:

function (array|object $data, array|int|string $key, int $index, GridView $grid): ?Tr
  • $data: the data model being rendered
  • $key: the key associated with the data model
  • $index: the zero-based index of the data model in the model array
  • $grid: the GridView object

The callback should return either:

  • a {@see \Yiisoft\Html\Tag\Tr} instance representing a table row to be rendered before the data row
  • or null if no additional row should be rendered
return self

New instance with the before row callback.

                public function beforeRow(?Closure $callback): self
{
    $new = clone $this;
    $new->beforeRowCallback = $callback;
    return $new;
}

            
bodyCellAttributes() public method

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;
}

            
bodyRowAttributes() public method

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:

function (array|object $data, BodyRowContext $context): array

If an array passed, the attribute values also can be a callable that returns them. The signature of the callable should be:

function (array|object $data, BodyRowContext $context): mixed
return self

New instance with the body row attributes.

                public function bodyRowAttributes(Closure|array $attributes): self
{
    $new = clone $this;
    $new->bodyRowAttributes = $attributes;
    return $new;
}

            
columnGrouping() public method
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;
}

            
columns() public method

Return new instance with the specified column configurations.

public self columns ( Yiisoft\Yii\DataView\GridView\Column\ColumnInterface $columns )
$columns Yiisoft\Yii\DataView\GridView\Column\ColumnInterface

The grid column configuration. Each element represents the configuration for one particular grid column. For example,

[
    new SerialColumn(),
    new DetailColumn(),
    (new ActionColumn())->primaryKey('identity_id')->visibleButtons(['view' => true]),
]
return self

New instance with the column configurations.

                public function columns(ColumnInterface ...$columns): self
{
    $new = clone $this;
    $new->columns = $columns;
    return $new;
}

            
containerAttributes() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::containerAttributes()

Returns a new instance with the HTML attributes for container.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}

            
containerClass() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::containerClass()

Set new container classes.

Multiple classes can be set by passing them as separate arguments. null values are filtered out automatically.

public Yiisoft\Yii\DataView\GridView\GridView containerClass ( \BackedEnum|string|null $class )
$class \BackedEnum|string|null

One or more CSS class names to use. Pass null to skip a class.

return Yiisoft\Yii\DataView\GridView\GridView

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;
}

            
containerTag() public method
public Yiisoft\Yii\DataView\GridView\GridView containerTag ( string|null $tag )
$tag string|null

                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;
}

            
dataReader() public method
public Yiisoft\Yii\DataView\GridView\GridView dataReader ( \Yiisoft\Data\Reader\ReadableDataInterface $dataReader )
$dataReader \Yiisoft\Data\Reader\ReadableDataInterface

                final public function dataReader(ReadableDataInterface $dataReader): static
{
    $new = clone $this;
    $new->dataReader = $dataReader;
    return $new;
}

            
emptyCell() public method

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;
}

            
emptyCellAttributes() public method

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;
}

            
enableFooter() public method

Whether to show the footer section of the grid.

public self enableFooter ( boolean $enabled true )
$enabled boolean

Whether to show the footer section of the grid.

return self

New instance with the footer section visibility setting.

                public function enableFooter(bool $enabled = true): self
{
    $new = clone $this;
    $new->isFooterEnabled = $enabled;
    return $new;
}

            
enableHeader() public method

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;
}

            
encodeHeader() public method
public Yiisoft\Yii\DataView\GridView\GridView encodeHeader ( boolean $encode )
$encode boolean

                final public function encodeHeader(bool $encode): static
{
    $new = clone $this;
    $new->encodeHeader = $encode;
    return $new;
}

            
filterCellAttributes() public method

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;
}

            
filterCellInvalidClass() public method

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;
}

            
filterErrorsContainerAttributes() public method

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;
}

            
filterFormAttributes() public method

public self filterFormAttributes ( array $attributes )
$attributes array

                public function filterFormAttributes(array $attributes): self
{
    $new = clone $this;
    $new->filterFormAttributes = $attributes;
    return $new;
}

            
filterFormId() public method

public self filterFormId ( string $id )
$id string

                public function filterFormId(string $id): self
{
    $new = clone $this;
    $new->filterFormId = $id;
    return $new;
}

            
footerRowAttributes() public method

Returns a new instance with the HTML attributes for footer row.

public self footerRowAttributes ( array $attributes )
$attributes array

Attribute values indexed by attribute names.

return self

New instance with the footer row attributes.

                public function footerRowAttributes(array $attributes): self
{
    $new = clone $this;
    $new->footerRowAttributes = $attributes;
    return $new;
}

            
getDataReader() protected method
protected \Yiisoft\Data\Reader\ReadableDataInterface getDataReader ( )

                final protected function getDataReader(): ReadableDataInterface
{
    if ($this->dataReader === null) {
        throw new DataReaderNotSetException();
    }
    return $this->dataReader;
}

            
getDefaultPageSize() protected method
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;
}

            
getNoResultsContent() protected method
protected string getNoResultsContent ( )

                final protected function getNoResultsContent(): string
{
    $text = $this->translator->translate(
        $this->noResultsText,
        category: $this->translationCategory,
    );
    return str_replace('{text}', $text, $this->noResultsTemplate);
}

            
header() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::header()

Return new instance with the header for the grid.

public Yiisoft\Yii\DataView\GridView\GridView header ( string $content )
$content string

The header of the grid.

{@see \Yiisoft\Yii\DataView\headerAttributes}

                final public function header(string $content): static
{
    $new = clone $this;
    $new->header = $content;
    return $new;
}

            
headerAttributes() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::headerAttributes()

Return new instance with the HTML attributes for the header.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}

            
headerCellAttributes() public method

Return new instance with the HTML attributes for the th tag.

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;
}

            
headerClass() public method
public Yiisoft\Yii\DataView\GridView\GridView headerClass ( \BackedEnum|string|null $class )
$class \BackedEnum|string|null

                public function headerClass(BackedEnum|string|null ...$class): static
{
    $new = clone $this;
    $new->headerAttributes['class'] = [];
    Html::addCssClass($new->headerAttributes, $class);
    return $new;
}

            
headerRowAttributes() public method

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;
}

            
headerTag() public method
public Yiisoft\Yii\DataView\GridView\GridView headerTag ( string|null $tag )
$tag string|null

                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;
}

            
id() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::id()

Returns a new instance with the id of the grid view, detail view, or list view.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}

            
ignoreMissingPage() public method
public Yiisoft\Yii\DataView\GridView\GridView ignoreMissingPage ( boolean $enabled )
$enabled boolean

                final public function ignoreMissingPage(bool $enabled): static
{
    $new = clone $this;
    $new->ignoreMissingPage = $enabled;
    return $new;
}

            
keepPageOnSort() public method

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;
}

            
keysetPaginationConfig() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::keysetPaginationConfig()

Set configuration for keyset pagination widget.

public Yiisoft\Yii\DataView\GridView\GridView keysetPaginationConfig ( array $config )
$config array

Widget config.

                final public function keysetPaginationConfig(array $config): static
{
    $new = clone $this;
    $new->keysetPaginationConfig = $config;
    return $new;
}

            
layout() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::layout()

Returns a new instance with the layout of the grid view, and list view.

public Yiisoft\Yii\DataView\GridView\GridView 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:

  • {header}: The header section.
  • {toolbar}: The toolbar section.

                final public function layout(string $view): static
{
    $new = clone $this;
    $new->layout = $view;
    return $new;
}

            
makeFilters() protected method

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];
}

            
multiSort() public method
public Yiisoft\Yii\DataView\GridView\GridView multiSort ( boolean $enable true )
$enable boolean

                final public function multiSort(bool $enable = true): static
{
    $new = clone $this;
    $new->multiSort = $enable;
    return $new;
}

            
noResultsCellAttributes() public method

public self noResultsCellAttributes ( array $attributes )
$attributes array

                public function noResultsCellAttributes(array $attributes): self
{
    $new = clone $this;
    $new->noResultsCellAttributes = $attributes;
    return $new;
}

            
noResultsTemplate() public method
public Yiisoft\Yii\DataView\GridView\GridView noResultsTemplate ( string $template )
$template string

                final public function noResultsTemplate(string $template): static
{
    $new = clone $this;
    $new->noResultsTemplate = $template;
    return $new;
}

            
noResultsText() public method
public Yiisoft\Yii\DataView\GridView\GridView noResultsText ( string $text )
$text string

                final public function noResultsText(string $text): static
{
    $new = clone $this;
    $new->noResultsText = $text;
    return $new;
}

            
offsetPaginationConfig() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::offsetPaginationConfig()

Set configuration for offset pagination widget.

public Yiisoft\Yii\DataView\GridView\GridView offsetPaginationConfig ( array $config )
$config array

Widget config.

                final public function offsetPaginationConfig(array $config): static
{
    $new = clone $this;
    $new->offsetPaginationConfig = $config;
    return $new;
}

            
pageNotFoundExceptionCallback() public method
public Yiisoft\Yii\DataView\GridView\GridView pageNotFoundExceptionCallback ( callable|null $callback )
$callback callable|null

                final public function pageNotFoundExceptionCallback(?callable $callback): static
{
    $new = clone $this;
    $new->pageNotFoundExceptionCallback = $callback;
    return $new;
}

            
pageParameterName() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::pageParameterName()

Return a new instance with the name of argument or query parameter for page.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}

            
pageParameterType() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::pageParameterType()

Creates a new instance with the specified page parameter type.

public Yiisoft\Yii\DataView\GridView\GridView pageParameterType ( \Yiisoft\Yii\DataView\Url\UrlParameterType $type )
$type \Yiisoft\Yii\DataView\Url\UrlParameterType

The new page parameter type.

return Yiisoft\Yii\DataView\GridView\GridView

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;
}

            
pageSizeAttributes() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::pageSizeAttributes()

Returns a new instance with the HTML attributes for page size wrapper tag.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}

            
pageSizeConstraint() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::pageSizeConstraint()

Get a new instance with a page size constraint set.

public Yiisoft\Yii\DataView\GridView\GridView pageSizeConstraint ( array|boolean|integer $pageSizeConstraint )
$pageSizeConstraint array|boolean|integer

Page size constraint. true - default only. false - no constraint. int - maximum page size. [int, int, ...] - a list of page sizes to choose from.

return Yiisoft\Yii\DataView\GridView\GridView

New instance.

                final public function pageSizeConstraint(array|int|bool $pageSizeConstraint): static
{
    $new = clone $this;
    $new->pageSizeConstraint = $pageSizeConstraint;
    return $new;
}

            
pageSizeParameterName() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::pageSizeParameterName()

Return a new instance with the name of argument or query parameter for page size.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}

            
pageSizeParameterType() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::pageSizeParameterType()

Creates a new instance with the specified page size parameter type.

public Yiisoft\Yii\DataView\GridView\GridView pageSizeParameterType ( \Yiisoft\Yii\DataView\Url\UrlParameterType $type )
$type \Yiisoft\Yii\DataView\Url\UrlParameterType

The new page size parameter type.

return Yiisoft\Yii\DataView\GridView\GridView

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;
}

            
pageSizeTag() public method
public Yiisoft\Yii\DataView\GridView\GridView pageSizeTag ( string|null $tag )
$tag string|null

                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;
}

            
pageSizeTemplate() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::pageSizeTemplate()

Returns a new instance with the page size template.

public Yiisoft\Yii\DataView\GridView\GridView 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 null.

The following tokens will be replaced with the corresponding values:

  • {widget} — page size widget.

                final public function pageSizeTemplate(?string $template): static
{
    $new = clone $this;
    $new->pageSizeTemplate = $template;
    return $new;
}

            
pageSizeWidget() public method
public Yiisoft\Yii\DataView\GridView\GridView pageSizeWidget ( Yiisoft\Yii\DataView\PageSize\PageSizeWidgetInterface|null $widget )
$widget Yiisoft\Yii\DataView\PageSize\PageSizeWidgetInterface|null

                final public function pageSizeWidget(?PageSizeWidgetInterface $widget): static
{
    $new = clone $this;
    $new->pageSizeWidget = $widget;
    return $new;
}

            
paginationWidget() public method
public Yiisoft\Yii\DataView\GridView\GridView paginationWidget ( Yiisoft\Yii\DataView\Pagination\PaginationWidgetInterface|null $widget )
$widget Yiisoft\Yii\DataView\Pagination\PaginationWidgetInterface|null

                final public function paginationWidget(?PaginationWidgetInterface $widget): static
{
    $new = clone $this;
    $new->paginationWidget = $widget;
    return $new;
}

            
prepareOrder() protected method

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,
    );
}

            
prepend() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::prepend()

Returns a new instance with HTML content to be added after the opening container tag.

public Yiisoft\Yii\DataView\GridView\GridView prepend ( string|\Stringable $prepend )
$prepend string|\Stringable

The HTML content to be prepended.

                final public function prepend(string|Stringable ...$prepend): static
{
    $new = clone $this;
    $new->prepend = implode('', $prepend);
    return $new;
}

            
previousPageParameterName() public method
public Yiisoft\Yii\DataView\GridView\GridView previousPageParameterName ( string $name )
$name string

                final public function previousPageParameterName(string $name): static
{
    $new = clone $this;
    $new->urlConfig = $this->urlConfig->withPreviousPageParameterName($name);
    return $new;
}

            
previousPageParameterType() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::previousPageParameterType()

Creates a new instance with the specified previous page parameter type.

public Yiisoft\Yii\DataView\GridView\GridView previousPageParameterType ( \Yiisoft\Yii\DataView\Url\UrlParameterType $type )
$type \Yiisoft\Yii\DataView\Url\UrlParameterType

The new previous page parameter type.

return Yiisoft\Yii\DataView\GridView\GridView

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;
}

            
render() public method
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();
}

            
renderItems() protected method

protected string renderItems ( array $items, \Yiisoft\Validator\Result $filterValidationResult, \Yiisoft\Data\Reader\ReadableDataInterface|null $preparedDataReader )
$items array
$filterValidationResult \Yiisoft\Validator\Result
$preparedDataReader \Yiisoft\Data\Reader\ReadableDataInterface|null

                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,
    );
    $tags = [];
    $hasFilters = false;
    $filterContext = new FilterContext(
        formId: $this->filterFormId,
        validationResult: $filterValidationResult,
        cellInvalidClass: $this->filterCellInvalidClass,
        errorsContainerAttributes: $this->filterErrorsContainerAttributes,
        urlParameterProvider: $this->urlParameterProvider,
    );
    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('&nbsp;')->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()->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) {
            $cell = $renderers[$i]->renderHeader($column, new Cell($this->headerCellAttributes), $globalContext);
            $tags[] = $cell === null
                ? Html::th('&nbsp;')->encode(false)
                : Html::th(attributes: $cell->getAttributes())
                    ->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('&nbsp;')->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);
            $tags[] = $cell->isEmptyContent()
                ? Html::td($this->emptyCell, $this->emptyCellAttributes)->encode(false)
                : Html::td(attributes: $this->prepareBodyCellAttributes($cell->getAttributes(), $context))
                    ->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();
    return
        $filtersForm
        . Html::tag('table', attributes: $this->tableAttributes)->open()
        . "\n"
        . implode("\n", $blocks)
        . "\n"
        . '</table>';
}

            
sortParameterName() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::sortParameterName()

Creates a new instance with the specified sort parameter name.

public Yiisoft\Yii\DataView\GridView\GridView sortParameterName ( string $name )
$name string

The new sort parameter name.

return Yiisoft\Yii\DataView\GridView\GridView

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;
}

            
sortParameterType() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::sortParameterType()

Creates a new instance with the specified sort parameter type.

public Yiisoft\Yii\DataView\GridView\GridView sortParameterType ( \Yiisoft\Yii\DataView\Url\UrlParameterType $type )
$type \Yiisoft\Yii\DataView\Url\UrlParameterType

The new sort parameter type.

return Yiisoft\Yii\DataView\GridView\GridView

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;
}

            
sortableHeaderAppend() public method

Return new instance with the content to be appended to sortable column headers.

public self sortableHeaderAppend ( string|\Stringable $content )
$content string|\Stringable

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;
}

            
sortableHeaderAscAppend() public method

Return new instance with the content to be appended to ascending sorted column headers.

public self sortableHeaderAscAppend ( string|\Stringable $content )
$content string|\Stringable

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;
}

            
sortableHeaderAscPrepend() public method

Return new instance with the content to be prepended to ascending sorted column headers.

public self sortableHeaderAscPrepend ( string|\Stringable $content )
$content string|\Stringable

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;
}

            
sortableHeaderDescAppend() public method

Return new instance with the content to be appended to descending sorted column headers.

public self sortableHeaderDescAppend ( string|\Stringable $content )
$content string|\Stringable

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;
}

            
sortableHeaderDescPrepend() public method

Return new instance with the content to be prepended to descending sorted column headers.

public self sortableHeaderDescPrepend ( string|\Stringable $content )
$content string|\Stringable

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;
}

            
sortableHeaderPrepend() public method

Return new instance with the content to be prepended to sortable column headers.

public self sortableHeaderPrepend ( string|\Stringable $content )
$content string|\Stringable

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;
}

            
sortableLinkAttributes() public method

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;
}

            
summaryAttributes() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::summaryAttributes()

Returns a new instance with the HTML attributes for summary wrapper tag.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}

            
summaryTag() public method
public Yiisoft\Yii\DataView\GridView\GridView summaryTag ( string|null $tag )
$tag string|null

                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;
}

            
summaryTemplate() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::summaryTemplate()

Returns a new instance with the summary template.

public Yiisoft\Yii\DataView\GridView\GridView 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:

  • {begin} — the starting row number (1-based) currently being displayed.
  • {end} — the ending row number (1-based) currently being displayed.
  • {count} — the number of rows currently being displayed.
  • {totalCount} — the total number of rows available.
  • {currentPage} — the page number (1-based) current being displayed.
  • {totalPages} — the number of pages available.

                final public function summaryTemplate(?string $template): static
{
    $new = clone $this;
    $new->summaryTemplate = $template;
    return $new;
}

            
tableAttributes() public method

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;
}

            
tableClass() public method

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;
}

            
tbodyAttributes() public method

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;
}

            
tbodyClass() public method

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;
}

            
toolbar() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::toolbar()

Return new instance with toolbar content.

public Yiisoft\Yii\DataView\GridView\GridView toolbar ( string $content )
$content string

The toolbar content.

                final public function toolbar(string $content): static
{
    $new = clone $this;
    $new->toolbar = $content;
    return $new;
}

            
urlArguments() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::urlArguments()

Return a new instance with arguments of the route.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}

            
urlCreator() public method
public Yiisoft\Yii\DataView\GridView\GridView urlCreator ( callable|null $urlCreator )
$urlCreator callable|null

                final public function urlCreator(?callable $urlCreator): static
{
    $new = clone $this;
    $new->urlCreator = $urlCreator;
    return $new;
}

            
urlParameterProvider() public method
public Yiisoft\Yii\DataView\GridView\GridView urlParameterProvider ( Yiisoft\Yii\DataView\Url\UrlParameterProviderInterface $provider )
$provider Yiisoft\Yii\DataView\Url\UrlParameterProviderInterface

                final public function urlParameterProvider(UrlParameterProviderInterface $provider): static
{
    $new = clone $this;
    $new->urlParameterProvider = $provider;
    return $new;
}

            
urlQueryParameters() public method

Defined in: Yiisoft\Yii\DataView\BaseListView::urlQueryParameters()

Return a new instance with query parameters of the route.

public Yiisoft\Yii\DataView\GridView\GridView 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;
}