Column
API reference › yii › grid › Column
5 subclasses
Column is the base class of all GridView column classes.
For more details and usage information on Column, see the guide article on data widgets.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$content | callable | This is a callable that will be used to generate the content of each cell. Default: null. | Column |
$contentOptions | array|Closure | The HTML attributes for the data cell tag. Default: []. | Column |
$filterOptions | array | The HTML attributes for the filter cell tag. Default: []. | Column |
$footer | string | The footer cell content. Default: null. | Column |
$footerOptions | array | The HTML attributes for the footer cell tag. Default: []. | Column |
$grid | GridView | The grid view object that owns this column. Default: null. | Column |
$header | string| | The header cell content. Default: null. | Column |
$headerOptions | array | The HTML attributes for the header cell tag. Default: []. | Column |
$options | array | The HTML attributes for the column group tag. Default: []. | Column |
$visible | bool | Whether this column is visible. Default: true. | Column |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__unset() | Sets an object property to null. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | yii\ |
renderDataCell() | Renders a data cell. | Column |
renderFilterCell() | Renders the filter cell. | Column |
renderFooterCell() | Renders the footer cell. | Column |
renderHeaderCell() | Renders the header cell. | Column |
getHeaderCellLabel() protected | Returns header cell label. | Column |
renderDataCellContent() protected | Renders the data cell content. | Column |
renderFilterCellContent() protected | Renders the filter cell content. | Column |
renderFooterCellContent() protected | Renders the footer cell content. | Column |
renderHeaderCellContent() protected | Renders the header cell content. | Column |
Property details
Section titled “Property details”$content
Section titled “$content ”public callable $content = nullThis is a callable that will be used to generate the content of each cell.
The signature of the function should be the following: function ($model, $key, $index, $column).
Where $model, $key, and $index refer to the model, key and index of the row currently being rendered
and $column is a reference to the Column object.
$contentOptions
Section titled “$contentOptions ”public array|Closure $contentOptions = []The HTML attributes for the data cell tag.
This can either be an array of
attributes or an anonymous function (Closure) that returns such an array.
The signature of the function should be the following: function ($model, $key, $index, $column).
Where $model, $key, and $index refer to the model, key and index of the row currently being rendered
and $column is a reference to the Column object.
A function may be used to assign different attributes to different rows based on the data in that row.
$footer
Section titled “$footer ”public string $footer = nullThe footer cell content.
Note that it will not be HTML-encoded.
$header
Section titled “$header ”public string|null $header = nullThe header cell content.
Note that it will not be HTML-encoded.
$visible
Section titled “$visible ”public bool $visible = trueWhether this column is visible.
Defaults to true.
Method details
Section titled “Method details”renderDataCell()
Section titled “renderDataCell() ”public function renderDataCell(mixed $model, mixed $key, int $index): stringRenders a data cell.
Parameters
| Parameter | Type | Description |
|---|---|---|
$model | mixed | The data model being rendered |
$key | mixed | The key associated with the data model |
$index | int | The zero-based index of the data item among the item array returned by GridView::$dataProvider. |
Returns
string: The rendering result
renderFilterCell()
Section titled “renderFilterCell() ”public function renderFilterCell(): mixedRenders the filter cell.
Returns
mixed
renderFooterCell()
Section titled “renderFooterCell() ”public function renderFooterCell(): mixedRenders the footer cell.
Returns
mixed
renderHeaderCell()
Section titled “renderHeaderCell() ”public function renderHeaderCell(): mixedRenders the header cell.
Returns
mixed
getHeaderCellLabel()
Section titled “getHeaderCellLabel() ”protected function getHeaderCellLabel(): stringReturns header cell label.
This method may be overridden to customize the label of the header cell.
Returns
string: Label
Since
2.0.8
renderDataCellContent()
Section titled “renderDataCellContent() ”protected function renderDataCellContent(mixed $model, mixed $key, int $index): stringRenders the data cell content.
Parameters
| Parameter | Type | Description |
|---|---|---|
$model | mixed | The data model |
$key | mixed | The key associated with the data model |
$index | int | The zero-based index of the data model among the models array returned by GridView::$dataProvider. |
Returns
string: The rendering result
renderFilterCellContent()
Section titled “renderFilterCellContent() ”protected function renderFilterCellContent(): stringRenders the filter cell content.
The default implementation simply renders a space. This method may be overridden to customize the rendering of the filter cell (if any).
Returns
string: The rendering result
renderFooterCellContent()
Section titled “renderFooterCellContent() ”protected function renderFooterCellContent(): stringRenders the footer cell content.
The default implementation simply renders $footer.
This method may be overridden to customize the rendering of the footer cell.
Returns
string: The rendering result
renderHeaderCellContent()
Section titled “renderHeaderCellContent() ”protected function renderHeaderCellContent(): stringRenders the header cell content.
The default implementation simply renders $header.
This method may be overridden to customize the rendering of the header cell.
Returns
string: The rendering result