Trait kartik\grid\ColumnTrait
ColumnTrait maintains generic methods used by all column widgets in kartik\grid\GridView.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$columnKey | string | An unique identifier for the Column. | kartik\grid\ColumnTrait |
$hAlign | string | The horizontal alignment of each column. | 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
Property | Type | Description | Defined 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
Method | Description | Defined 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
Method | Description | Defined 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
The internally generated client script to initialize
Collection of row data for the column for the current page
The view instance
An unique identifier for the Column. If not set, it will be automatically generated.
The horizontal alignment of each column. Should be one of GridView::ALIGN_LEFT, GridView::ALIGN_RIGHT, or GridView::ALIGN_CENTER.
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.
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.
Whether to just hide the page summary display but still calculate the summary based on $pageSummary settings
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.
Whether to force no wrapping on all table cells in the column
See also http://www.w3schools.com/cssref/pr_text_white-space.asp.
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.
- the
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().
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.
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 contentappend
: string, a suffix string that will be appended after the pageSummary contentcolspan
: int, the column count that will be merged.data-colspan-dir
: string, whetherltr
orrtl
. Defaults toltr
. If this is set toltr
the columns will be merged starting from this column to the right (i.e. left to right). If this is set tortl
, the columns will be merged starting from this column to the left (i.e. right to left).
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
.
The vertical alignment of each column. Should be one of GridView::ALIGN_TOP, GridView::ALIGN_BOTTOM, or GridView::ALIGN_MIDDLE.
The width of each column (matches the CSS width property).
Method Details
Calculates the summary of an input data based on page summary aggregration function.
protected float calculateSummary ( ) |
Checks if the filter input types are valid
protected void checkValidFilters ( ) | ||
throws | yii\base\InvalidConfigException |
---|
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. |
Get the raw footer cell content.
protected string getFooterCellContent ( ) | ||
return | string | The rendered result |
---|
Gets the raw page summary cell content.
protected string getPageSummaryCellContent ( ) | ||
return | string | The rendered result |
---|
Initializes the column key
protected void initColumnKey ( ) |
Initialize column settings
public void initColumnSettings ( $settings = [] ) | ||
$settings | array |
Initializes grid grouping
protected void initGrouping ( ) |
Initialize column specific JS functionality whenever pjax request completes
protected void initPjax ( $script = '' ) | ||
$script | string | The js script to be used as a callback |
Check if the alignment provided is valid
protected boolean isValidAlignment ( $type = 'hAlign' ) | ||
$type | string | The alignment type |
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 |
Parses and formats a grid column
protected void parseFormat ( ) |
Parses grid grouping and sets data attributes
protected void parseGrouping ( &$options, $model, $key, $index ) | ||
$options | array | |
$model | yii\base\Model | |
$key | mixed | |
$index | integer |
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 |
Checks hidden
property and hides the column from display
protected void parseVisibility ( ) |
Renders the filter cell.
public string renderFilterCell ( ) |
Renders the header cell.
public string renderHeaderCell ( ) |
Renders the page summary cell.
public string renderPageSummaryCell ( ) | ||
return | string | The rendered result |
---|
Renders the page summary cell content.
protected string renderPageSummaryCellContent ( ) | ||
return | string | The rendered result |
---|
Store all rows for the column for the current page
protected void setPageRows ( ) |