Class humhub\components\export\DataColumn

Inheritancehumhub\components\export\DataColumn » humhub\components\export\Column » yii\base\BaseObject
Subclasseshumhub\components\export\DateTimeColumn

DataColumn is the default column type for the humhub\components\export\SpreadsheetExport widget.

This class was originally developed by Paul Klimov klimov.paul@gmail.com and his project csv-grid (https://github.com/yii2tech/csv-grid).

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$attribute string The attribute name associated with this column. humhub\components\export\DataColumn
$content callable This is a callable that will be used to generate the content of each cell. humhub\components\export\Column
$dataType string|null Specify data type humhub\components\export\Column
$footer string The footer cell content. humhub\components\export\Column
$format string|array In which format should the value of each data model be displayed as (e.g. "raw", "text", "html", ['date', 'php:Y-m-d']). humhub\components\export\DataColumn
$grid humhub\components\export\SpreadsheetExport The grid view object that owns this column. humhub\components\export\Column
$header string The header cell content. humhub\components\export\Column
$label string Label to be displayed in the header cell. humhub\components\export\DataColumn
$styles array Containing style information humhub\components\export\Column
$value string|Closure Anonymous function or a string that is used to determine the value for the current column. humhub\components\export\DataColumn
$visible boolean Whether this column is visible. humhub\components\export\Column

Public Methods

Hide inherited methods

MethodDescriptionDefined By
getDataCellValue() Returns the data cell value. humhub\components\export\DataColumn
renderDataCellContent() Renders the data cell content. humhub\components\export\DataColumn
renderFooterCellContent() Renders the footer cell content. humhub\components\export\Column
renderHeaderCellContent() Renders the header cell content. humhub\components\export\DataColumn

Property Details

$attribute public property

The attribute name associated with this column. When neither $content nor $value is specified, the value of the specified attribute will be retrieved from each data model and displayed.

Also, if $label is not specified, the label associated with the attribute will be displayed.

public string $attribute null
$format public property

In which format should the value of each data model be displayed as (e.g. "raw", "text", "html", ['date', 'php:Y-m-d']). Supported formats are determined by the \humhub\components\export\GridView::formatter used by he \humhub\components\export\GridView. Default format is "text" which will format the value as an HTML-encoded plain text when \yii\i18n\Formatter is used as the \humhub\components\export\GridView::$formatter of the GridView.

public string|array $format 'text'
$label public property

Label to be displayed in the header cell. If it is not set and the models provided by the GridViews data provider are instances of \yii\db\ActiveRecord, the label will be determined using \yii\db\ActiveRecord::getAttributeLabel(). Otherwise \yii\helpers\Inflector::camel2words() will be used to get a label.

public string $label null
$value public property

Anonymous function or a string that is used to determine the value for the current column.

If this is an anonymous function, it will be called for each row and the return value will be used as the value to display for every data model. The signature of this function should be: 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 humhub\components\export\DataColumn object.

You may also set this property to a string representing the attribute name to be displayed in this column.

If this is not set, $model[$attribute] will be used to obtain the value, where $attribute is the value of $attribute.

public string|Closure $value null

Method Details

getDataCellValue() public method

Returns the data cell value.

public string getDataCellValue ( $model, $key, $index )
$model mixed

The data model

$key mixed

The key associated with the data model

$index integer

Zero-based index of data model among models array returned by \humhub\components\export\GridView::dataProvider.

return string

The data cell value

renderDataCellContent() public method

Renders the data cell content.

public string renderDataCellContent ( $model, $key, $index )
$model mixed

The data model

$key mixed

The key associated with the data model

$index integer

Zero-based index of data model among models array returned by \humhub\components\export\GridView::dataProvider.

return string

The rendering result

renderHeaderCellContent() public method

Renders the header cell content.

The default implementation simply renders $header. This method may be overridden to customize the rendering of the header cell.

public string renderHeaderCellContent ( )
return string

The rendering result