Skip to content
PHP Ecosystem
Explore

Column

API reference › CSV Export › Column

classyii2\extensions\csvexport\Column
Extendsyii\base\BaseObject
Implementsyii\base\Configurable
Sourcesrc/Column.php
2 subclasses

Column is the base class of all CsvExporter column classes.

PropertyTypeDescriptionDefined by
$contentcallable(mixed, mixed, int, Column): mixed|nullThis is a callable that will be used to generate the content of each cell. Default: null.Column
$footerstring|nullFooter cell content, or null to use the exporter fallback. Default: null.Column
$gridCsvExporterThe exporter that owns this column.Column
$headerstring|nullHeader cell content, or null to use the exporter fallback. Default: null.Column
$visibleboolWhether this column is visible. Defaults to true. Default: true.Column
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.yii\base\BaseObject
__get()Returns the value of an object property.yii\base\BaseObject
__isset()Checks if a property is set, i.e. defined and not null.yii\base\BaseObject
__set()Sets value of an object property.yii\base\BaseObject
__unset()Sets an object property to null.yii\base\BaseObject
canGetProperty()Returns a value indicating whether a property can be read.yii\base\BaseObject
canSetProperty()Returns a value indicating whether a property can be set.yii\base\BaseObject
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
getGrid()Returns the exporter that owns this column.Column
hasMethod()Returns a value indicating whether a method is defined.yii\base\BaseObject
hasProperty()Returns a value indicating whether a property is defined.yii\base\BaseObject
init()Initializes the object.yii\base\BaseObject
renderDataCellContent()Renders a data cell using the content callback or the exporter fallback.Column
renderFooterCellContent()Renders the footer cell using configured text or the exporter fallback.Column
renderHeaderCellContent()Renders the header cell using configured text or the exporter fallback.Column
setGrid()Sets the exporter that owns this column.Column
public callable(mixed, mixed, int, yii2\extensions\csvexport\Column): mixed|null $content = null

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 function getGrid(): yii2\extensions\csvexport\CsvExporter

Returns the exporter that owns this column.

Returns

CsvExporter: The owning exporter.

Throws

public function renderDataCellContent(mixed $model, mixed $key, int $index): mixed

Renders a data cell using the content callback or the exporter fallback.

Parameters

ParameterTypeDescription
$modelmixedData row from the effective source.
$keymixedKey associated with the data row.
$indexintZero-based row index across the export.

Returns

mixed: The result of content, or the exporter’s empty-cell value when content is unset.

Throws

public function renderFooterCellContent(): string

Renders the footer cell using configured text or the exporter fallback.

Returns

string: The footer text, or the exporter’s empty-cell value when the footer is unset or blank.

Throws

public function renderHeaderCellContent(): string

Renders the header cell using configured text or the exporter fallback.

Returns

string: The header text, or the exporter’s empty-cell value when the header is unset or blank.

Throws

public function setGrid(yii2\extensions\csvexport\CsvExporter $grid): void

Sets the exporter that owns this column.

Parameters

ParameterTypeDescription
$gridCsvExporterExporter that renders this column.