PHP Class yii\grid\Column

Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends yii\base\Object
Show file Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$content This 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 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.
$filterOptions the HTML attributes for the filter cell tag.
$footer the footer cell content. Note that it will not be HTML-encoded.
$footerOptions the HTML attributes for the footer cell tag.
$grid the grid view object that owns this column.
$header the header cell content. Note that it will not be HTML-encoded.
$headerOptions the HTML attributes for the header cell tag.
$options the HTML attributes for the column group tag.
$visible whether this column is visible. Defaults to true.

Public Methods

Method Description
renderDataCell ( mixed $model, mixed $key, integer $index ) : string Renders a data cell.
renderFilterCell ( ) Renders the filter cell.
renderFooterCell ( ) Renders the footer cell.
renderHeaderCell ( ) Renders the header cell.

Protected Methods

Method Description
getHeaderCellLabel ( ) : string Returns header cell label.
renderDataCellContent ( mixed $model, mixed $key, integer $index ) : string Renders the data cell content.
renderFilterCellContent ( ) : string Renders the filter cell content.
renderFooterCellContent ( ) : string Renders the footer cell content.
renderHeaderCellContent ( ) : string Renders the header cell content.

Method Details

getHeaderCellLabel() protected method

This method may be overridden to customize the label of the header cell.
Since: 2.0.8
protected getHeaderCellLabel ( ) : string
return string label

renderDataCell() public method

Renders a data cell.
public renderDataCell ( mixed $model, mixed $key, integer $index ) : string
$model mixed the data model being rendered
$key mixed the key associated with the data model
$index integer the zero-based index of the data item among the item array returned by [[GridView::dataProvider]].
return string the rendering result

renderDataCellContent() protected method

Renders the data cell content.
protected renderDataCellContent ( mixed $model, mixed $key, integer $index ) : string
$model mixed the data model
$key mixed the key associated with the data model
$index integer the zero-based index of the data model among the models array returned by [[GridView::dataProvider]].
return string the rendering result

renderFilterCell() public method

Renders the filter cell.
public renderFilterCell ( )

renderFilterCellContent() protected method

The default implementation simply renders a space. This method may be overridden to customize the rendering of the filter cell (if any).
protected renderFilterCellContent ( ) : string
return string the rendering result

renderFooterCell() public method

Renders the footer cell.
public renderFooterCell ( )

renderFooterCellContent() protected method

The default implementation simply renders [[footer]]. This method may be overridden to customize the rendering of the footer cell.
protected renderFooterCellContent ( ) : string
return string the rendering result

renderHeaderCell() public method

Renders the header cell.
public renderHeaderCell ( )

renderHeaderCellContent() protected method

The default implementation simply renders [[header]]. This method may be overridden to customize the rendering of the header cell.
protected renderHeaderCellContent ( ) : string
return string the rendering result

Property Details

$content public property

This 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.
public $content

$contentOptions public property

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.
See also: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $contentOptions

$filterOptions public property

the HTML attributes for the filter cell tag.
See also: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $filterOptions

$footerOptions public property

the HTML attributes for the footer cell tag.
See also: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $footerOptions

$grid public property

the grid view object that owns this column.
public $grid

$header public property

the header cell content. Note that it will not be HTML-encoded.
public $header

$headerOptions public property

the HTML attributes for the header cell tag.
See also: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $headerOptions

$options public property

the HTML attributes for the column group tag.
See also: yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
public $options

$visible public property

whether this column is visible. Defaults to true.
public $visible