Property |
Type |
Description |
|
$afterRow |
|
an anonymous function that is called once AFTER rendering each data model.
It should have the similar signature as [[rowOptions]]. The return result of the function
will be rendered directly. |
|
$beforeRow |
|
an anonymous function that is called once BEFORE rendering each data model.
It should have the similar signature as [[rowOptions]]. The return result of the function
will be rendered directly. |
|
$caption |
|
the caption of the grid table |
|
$captionOptions |
|
the HTML attributes for the caption element. |
|
$columns |
|
grid column configuration. Each array element represents the configuration
for one particular grid column. For example,
php
[
['class' => SerialColumn::className()],
[
'class' => DataColumn::className(), // this line is optional
'attribute' => 'name',
'format' => 'text',
'label' => 'Name',
],
['class' => CheckboxColumn::className()],
]
If a column is of class DataColumn, the "class" element can be omitted.
As a shortcut format, a string may be used to specify the configuration of a data column
which only contains [[DataColumn::attribute|attribute]], [[DataColumn::format|format]],
and/or [[DataColumn::label|label]] options: "attribute:format:label".
For example, the above "name" column can also be specified as: "name:text:Name".
Both "format" and "label" are optional. They will take default values if absent.
Using the shortcut format the configuration for columns in simple cases would look like this:
php
[
'id',
'amount:currency:Total Amount',
'created_at:datetime',
]
When using a [[dataProvider]] with active records, you can also display values from related records,
e.g. the name attribute of the author relation:
php
shortcut syntax
'author.name',
full syntax
[
'attribute' => 'author.name',
...
]
|
|
$dataColumnClass |
|
the default data column class if the class name is not explicitly specified when configuring a data column.
Defaults to 'yii\grid\DataColumn'. |
|
$emptyCell |
|
the HTML display when the content of a cell is empty.
This property is used to render cells that have no defined content,
e.g. empty footer or filter cells.
Note that this is not used by the DataColumn if a data item is null. In that case
the [[\yii\i18n\Formatter::nullDisplay|nullDisplay]] property of the [[formatter]] will
be used to indicate an empty data value. |
|
$filterErrorOptions |
|
the options for rendering every filter error message.
This is mainly used by [[Html::error()]] when rendering an error message next to every filter input field. |
|
$filterErrorSummaryOptions |
|
the options for rendering the filter error summary.
Please refer to [[Html::errorSummary()]] for more details about how to specify the options. |
|
$filterModel |
|
the model that keeps the user-entered filter data. When this property is set,
the grid view will enable column-based filtering. Each data column by default will display a text field
at the top that users can fill in to filter the data.
Note that in order to show an input field for filtering, a column must have its [[DataColumn::attribute]]
property set and the attribute should be active in the current scenario of $filterModel or have
[[DataColumn::filter]] set as the HTML code for the input field.
When this property is not set (null) the filtering feature is disabled. |
|
$filterPosition |
|
whether the filters should be displayed in the grid view. Valid values include:
- [[FILTER_POS_HEADER]]: the filters will be displayed on top of each column's header cell.
- [[FILTER_POS_BODY]]: the filters will be displayed right below each column's header cell.
- [[FILTER_POS_FOOTER]]: the filters will be displayed below each column's footer cell. |
|
$filterRowOptions |
|
the HTML attributes for the filter row element. |
|
$filterSelector |
|
additional jQuery selector for selecting filter input fields |
|
$filterUrl |
|
the URL for returning the filtering result. [[Url::to()]] will be called to
normalize the URL. If not set, the current controller action will be used.
When the user makes change to any filter input, the current filtering inputs will be appended
as GET parameters to this URL. |
|
$footerRowOptions |
|
the HTML attributes for the table footer row. |
|
$formatter |
|
the formatter used to format model attribute values into displayable texts.
This can be either an instance of [[Formatter]] or an configuration array for creating the [[Formatter]]
instance. If this property is not set, the "formatter" application component will be used. |
|
$headerRowOptions |
|
the HTML attributes for the table header row. |
|
$layout |
|
the layout that determines how different sections of the list view should be organized.
The following tokens will be replaced with the corresponding section contents:
- {summary}: the summary section. See [[renderSummary()]].
- {errors}: the filter model error summary. See GridView::renderErrors.
- {items}: the list items. See GridView::renderItems.
- {sorter}: the sorter. See [[renderSorter()]].
- {pager}: the pager. See [[renderPager()]]. |
|
$options |
|
the HTML attributes for the container tag of the grid view.
The "tag" element specifies the tag name of the container element and defaults to "div". |
|
$rowOptions |
|
the HTML attributes for the table body rows. This can be either an array
specifying the common HTML attributes for all body rows, or an anonymous function that
returns an array of the HTML attributes. The anonymous function will be called once for every
data model returned by [[dataProvider]]. It should have the following signature:
php
function ($model, $key, $index, $grid)
- $model: the current data model being rendered
- $key: the key value associated with the current data model
- $index: the zero-based index of the data model in the model array returned by [[dataProvider]]
- $grid: the GridView object |
|
$showFooter |
|
whether to show the footer section of the grid table. |
|
$showHeader |
|
whether to show the header section of the grid table. |
|
$showOnEmpty |
|
whether to show the grid view if [[dataProvider]] returns no data. |
|
$tableOptions |
|
the HTML attributes for the grid table element. |
|