Trait kartik\grid\ColumnTrait

Implemented bykartik\grid\ActionColumn, kartik\grid\BooleanColumn, kartik\grid\CheckboxColumn, kartik\grid\DataColumn, kartik\grid\EditableColumn, kartik\grid\EnumColumn, kartik\grid\ExpandRowColumn, kartik\grid\FormulaColumn, kartik\grid\RadioColumn, kartik\grid\SerialColumn
Available since version1.0

ColumnTrait maintains generic methods used by all column widgets in kartik\grid\GridView.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$columnKey string An unique identifier for the Column. kartik\grid\ColumnTrait
$hAlign string The horizontal alignment of each column. kartik\grid\ColumnTrait
$hidden boolean Whether the column is hidden from display. kartik\grid\ColumnTrait
$hiddenFromExport boolean|array Whether the column is hidden in export output. kartik\grid\ColumnTrait
$hidePageSummary boolean Whether to just hide the page summary display but still calculate the summary based on $pageSummary settings kartik\grid\ColumnTrait
$mergeHeader boolean Whether to merge the header title row and the filter row. kartik\grid\ColumnTrait
$noWrap boolean Whether to force no wrapping on all table cells in the column kartik\grid\ColumnTrait
$pageSummary boolean|string|Closure The page summary that is displayed above the footer. kartik\grid\ColumnTrait
$pageSummaryFormat string|array|Closure In which format should the value of each data model be displayed as (e.g. "raw", "text", "html", ['date', 'php:Y-m-d']). kartik\grid\ColumnTrait
$pageSummaryFunc string|Closure The summary function that will be used to calculate the page summary for the column. kartik\grid\ColumnTrait
$pageSummaryOptions array HTML attributes for the page summary cell. kartik\grid\ColumnTrait
$stripTagsFromExport boolean Whether to strip HTML tags from the column during export. kartik\grid\ColumnTrait
$vAlign string The vertical alignment of each column. kartik\grid\ColumnTrait
$width string The width of each column (matches the CSS width property). kartik\grid\ColumnTrait

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$_clientScript string The internally generated client script to initialize kartik\grid\ColumnTrait
$_rows array Collection of row data for the column for the current page kartik\grid\ColumnTrait
$_view yii\web\View The view instance kartik\grid\ColumnTrait

Public Methods

Hide inherited methods

MethodDescriptionDefined By
initColumnSettings() Initialize column settings kartik\grid\ColumnTrait
parseExcelFormats() Parses Excel Cell Formats for export kartik\grid\ColumnTrait
renderFilterCell() Renders the filter cell. kartik\grid\ColumnTrait
renderHeaderCell() Renders the header cell. kartik\grid\ColumnTrait
renderPageSummaryCell() Renders the page summary cell. kartik\grid\ColumnTrait

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
calculateSummary() Calculates the summary of an input data based on page summary aggregration function. kartik\grid\ColumnTrait
checkValidFilters() Checks if the filter input types are valid kartik\grid\ColumnTrait
fetchContentOptions() Parses and fetches updated content options for grid visibility and format kartik\grid\ColumnTrait
getFooterCellContent() Get the raw footer cell content. kartik\grid\ColumnTrait
getPageSummaryCellContent() Gets the raw page summary cell content. kartik\grid\ColumnTrait
initColumnKey() Initializes the column key kartik\grid\ColumnTrait
initGrouping() Initializes grid grouping kartik\grid\ColumnTrait
initPjax() Initialize column specific JS functionality whenever pjax request completes kartik\grid\ColumnTrait
isValidAlignment() Check if the alignment provided is valid kartik\grid\ColumnTrait
parseFormat() Parses and formats a grid column kartik\grid\ColumnTrait
parseGrouping() Parses grid grouping and sets data attributes kartik\grid\ColumnTrait
parseVal() Parses a value if Closure and returns the right value kartik\grid\ColumnTrait
parseVisibility() Checks hidden property and hides the column from display kartik\grid\ColumnTrait
renderPageSummaryCellContent() Renders the page summary cell content. kartik\grid\ColumnTrait
setPageRows() Store all rows for the column for the current page kartik\grid\ColumnTrait

Property Details

$_clientScript protected property

The internally generated client script to initialize

protected string $_clientScript ''
$_rows protected property

Collection of row data for the column for the current page

protected array $_rows = []
$_view protected property

The view instance

protected yii\web\View $_view null
$columnKey public property

An unique identifier for the Column. If not set, it will be automatically generated.

public string $columnKey null
$hAlign public property

The horizontal alignment of each column. Should be one of GridView::ALIGN_LEFT, GridView::ALIGN_RIGHT, or GridView::ALIGN_CENTER.

public string $hAlign null
$hidden public property

Whether the column is hidden from display. This is different than the visible property, in the sense, that the column is rendered, but hidden from display. This will allow you to still export the column using the export function.

public boolean $hidden null
$hiddenFromExport public property

Whether the column is hidden in export output. If set to boolean true, it will hide the column for all export formats. If set as an array, it will accept the list of GridView export formats and hide output only for them.

$hidePageSummary public property

Whether to just hide the page summary display but still calculate the summary based on $pageSummary settings

public boolean $hidePageSummary null
$mergeHeader public property

Whether to merge the header title row and the filter row. This will not render the filter for the column and can be used when filter is set to false. Defaults to false. This is only applicable when kartik\grid\GridView::$filterPosition for the grid is set to kartik\grid\GridView::FILTER_POS_BODY.

public boolean $mergeHeader null
$noWrap public property

Whether to force no wrapping on all table cells in the column

See also http://www.w3schools.com/cssref/pr_text_white-space.asp.

public boolean $noWrap null
$pageSummary public property

The page summary that is displayed above the footer. You can set it to one of the following:

  • false: the summary will not be displayed.
  • true: the page summary for the column will be calculated and displayed using the $pageSummaryFunc setting.
  • string: will be displayed as is.
  • Closure: you can set it to an anonymous function with the following signature:

    // example 1
    function ($summary, $data, $widget) { return 'Count is ' . $summary; }
    // example 2
    function ($summary, $data, $widget) { return 'Range ' . min($data) . ' to ' . max($data); }
    

    where:

    • the $summary variable will be replaced with the calculated summary using the $pageSummaryFunc setting.
    • the $data variable will contain array of the selected page rows for the column.
$pageSummaryFormat 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 formatter used by the kartik\grid\GridView. Default format is "text" which will format the value as an HTML-encoded plain text when yii\i18n\Formatter is used as the formatter of the GridView.

If this is not set - it will default to the format setting for the Column.

See also yii\i18n\Formatter::format().

$pageSummaryFunc public property

The summary function that will be used to calculate the page summary for the column. If setting as Closure, you can set it to an anonymous function with the following signature:

function ($data)
  • the $data variable will contain array of the selected page rows for the column.
$pageSummaryOptions public property

HTML attributes for the page summary cell. The following special attributes are available:

  • prepend: string, a prefix string that will be prepended before the pageSummary content
  • append: string, a suffix string that will be appended after the pageSummary content
  • colspan: int, the column count that will be merged.
  • data-colspan-dir: string, whether ltr or rtl. Defaults to ltr. If this is set to ltr the columns will be merged starting from this column to the right (i.e. left to right). If this is set to rtl, the columns will be merged starting from this column to the left (i.e. right to left).
public array $pageSummaryOptions null
$stripTagsFromExport public property

Whether to strip HTML tags from the column during export. This can be useful for column data that is mainly a hyperlink or contains HTML markup that are not needed for display at export. Defaults to false.

$vAlign public property

The vertical alignment of each column. Should be one of GridView::ALIGN_TOP, GridView::ALIGN_BOTTOM, or GridView::ALIGN_MIDDLE.

public string $vAlign null
$width public property

The width of each column (matches the CSS width property).

See also http://www.w3schools.com/cssref/pr_dim_width.asp.

public string $width null

Method Details

calculateSummary() protected method

Calculates the summary of an input data based on page summary aggregration function.

protected float calculateSummary ( )
checkValidFilters() protected method

Checks if the filter input types are valid

protected void checkValidFilters ( )
throws yii\base\InvalidConfigException
fetchContentOptions() protected method

Parses and fetches updated content options for grid visibility and format

protected array fetchContentOptions ( $model, $key, $index )
$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 kartik\grid\GridView::$dataProvider.

getFooterCellContent() protected method

Get the raw footer cell content.

protected string getFooterCellContent ( )
return string

The rendered result

getPageSummaryCellContent() protected method

Gets the raw page summary cell content.

protected string getPageSummaryCellContent ( )
return string

The rendered result

initColumnKey() protected method

Initializes the column key

protected void initColumnKey ( )
initColumnSettings() public method

Initialize column settings

public void initColumnSettings ( $settings = [] )
$settings array
initGrouping() protected method

Initializes grid grouping

protected void initGrouping ( )
initPjax() protected method

Initialize column specific JS functionality whenever pjax request completes

protected void initPjax ( $script '' )
$script string

The js script to be used as a callback

isValidAlignment() protected method

Check if the alignment provided is valid

protected boolean isValidAlignment ( $type 'hAlign' )
$type string

The alignment type

parseExcelFormats() public method

Parses Excel Cell Formats for export

public void parseExcelFormats ( &$options, $model, $key, $index )
$options array

The HTML attributes for the cell

$model yii\base\Model

The current model being rendered

$key mixed

The primary key value for the model

$index integer

The zero-based index of the model being rendered

parseFormat() protected method

Parses and formats a grid column

protected void parseFormat ( )
parseGrouping() protected method

Parses grid grouping and sets data attributes

protected void parseGrouping ( &$options, $model, $key, $index )
$options array
$model yii\base\Model
$key mixed
$index integer
parseVal() protected method

Parses a value if Closure and returns the right value

protected mixed parseVal ( $var, $model, $key, $index )
$var string|integer|Closure

The variable to parse

$model yii\base\Model

The model instance

$key string|object

The current model key value

$index integer

The index of the current record in the data provider

parseVisibility() protected method

Checks hidden property and hides the column from display

protected void parseVisibility ( )
renderFilterCell() public method

Renders the filter cell.

public string renderFilterCell ( )
renderHeaderCell() public method

Renders the header cell.

public string renderHeaderCell ( )
renderPageSummaryCell() public method

Renders the page summary cell.

public string renderPageSummaryCell ( )
return string

The rendered result

renderPageSummaryCellContent() protected method

Renders the page summary cell content.

protected string renderPageSummaryCellContent ( )
return string

The rendered result

setPageRows() protected method

Store all rows for the column for the current page

protected void setPageRows ( )