Column
API reference › CSV Export › Column
2 subclasses
Column is the base class of all CsvExporter column classes.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$content | callable(mixed, Column): mixed| | This is a callable that will be used to generate the content of each cell. Default: null. | Column |
$footer | string| | Footer cell content, or null to use the exporter fallback. Default: null. | Column |
$grid | CsvExporter | The exporter that owns this column. | Column |
$header | string| | Header cell content, or null to use the exporter fallback. Default: null. | Column |
$visible | bool | Whether this column is visible. Defaults to true. 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\ |
getGrid() | Returns the exporter that owns this column. | Column |
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\ |
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 |
Property details
Section titled “Property details”$content
Section titled “$content ”public callable(mixed, mixed, int, yii2\extensions\csvexport\Column): mixed|null $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.
Method details
Section titled “Method details”getGrid()
Section titled “getGrid() ”public function getGrid(): yii2\extensions\csvexport\CsvExporterReturns the exporter that owns this column.
Returns
CsvExporter: The owning exporter.
Throws
yii\base\InvalidConfigException: if the column was not assigned to an exporter.
renderDataCellContent()
Section titled “renderDataCellContent() ”public function renderDataCellContent(mixed $model, mixed $key, int $index): mixedRenders a data cell using the content callback or the exporter fallback.
Parameters
| Parameter | Type | Description |
|---|---|---|
$model | mixed | Data row from the effective source. |
$key | mixed | Key associated with the data row. |
$index | int | Zero-based row index across the export. |
Returns
mixed: The result of content, or the exporter’s empty-cell value when content is unset.
Throws
yii\base\InvalidConfigException: if the fallback is needed and the column has no exporter.
renderFooterCellContent()
Section titled “renderFooterCellContent() ”public function renderFooterCellContent(): stringRenders 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
yii\base\InvalidConfigException: if the fallback is needed and the column has no exporter.
renderHeaderCellContent()
Section titled “renderHeaderCellContent() ”public function renderHeaderCellContent(): stringRenders 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
yii\base\InvalidConfigException: if the fallback is needed and the column has no exporter.
setGrid()
Section titled “setGrid() ”public function setGrid(yii2\extensions\csvexport\CsvExporter $grid): voidSets the exporter that owns this column.
Parameters
| Parameter | Type | Description |
|---|---|---|
$grid | CsvExporter | Exporter that renders this column. |