Class kartik\grid\ExpandRowColumn

Inheritancekartik\grid\ExpandRowColumn » kartik\grid\DataColumn » yii\grid\DataColumn » yii\grid\Column » yii\base\BaseObject
Implementsyii\base\Configurable
Uses Traitskartik\grid\ColumnTrait
Available since version1.0

An ExpandRowColumn can be used to expand a row and add content in a new row below it either directly or via ajax.

To add an ExpandRowColumn to the gridview, add it to the columns configuration as follows:

'columns' => [
    // ...
    [
        'class' => ExpandRowColumn::class,
        // you may configure additional properties here
    ],
]

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$allowBatchToggle boolean Allow batch expansion or batch collapse of all rows by clicking the header indicator. kartik\grid\ExpandRowColumn
$attribute string The attribute name associated with this column. yii\grid\DataColumn
$collapseAllTitle string Title to display on hover of collapse indicator at header. kartik\grid\ExpandRowColumn
$collapseIcon string Icon for the collapse indicator. kartik\grid\ExpandRowColumn
$collapseTitle string Title to display on hover of collapse indicator for each row. kartik\grid\ExpandRowColumn
$columnKey string An unique identifier for the Column. kartik\grid\ColumnTrait
$content callable This is a callable that will be used to generate the content of each cell. yii\grid\Column
$contentOptions array|Closure The HTML attributes for the data cell tag. yii\grid\Column
$defaultHeaderState integer Default state of the header. kartik\grid\ExpandRowColumn
$detail string|Closure The detail content (html markup) to be displayed in the expanded row. kartik\grid\ExpandRowColumn
$detailAnimationDuration string|integer The animation duration to slide up/down the detail row. kartik\grid\ExpandRowColumn
$detailOptions array|Closure The HTML attributes for the expanded table row. kartik\grid\ExpandRowColumn
$detailRowCssClass string The CSS class for the detail content table row. kartik\grid\ExpandRowColumn
$detailUrl string The url/action that would render the detail content via ajax. kartik\grid\ExpandRowColumn
$disabled boolean|Closure Whether the expand icon indicator is disabled. kartik\grid\ExpandRowColumn
$enableCache boolean Whether to enable caching of expanded row content while expanding the row using ajax triggered action (applicable when detailUrl is set). kartik\grid\ExpandRowColumn
$enableRowClick boolean Whether to toggle the expansion/collapse by clicking on the table row. kartik\grid\ExpandRowColumn
$enableSorting boolean Whether to allow sorting by this column. yii\grid\DataColumn
$encodeLabel boolean Whether the header label should be HTML-encoded. yii\grid\DataColumn
$expandAllTitle string Title to display on hover of expand indicator at header. kartik\grid\ExpandRowColumn
$expandIcon string Icon for the expand indicator. kartik\grid\ExpandRowColumn
$expandOneOnly boolean Whether to allow only one row to be expanded at a time and auto collapse other expanded rows whenever a row is expanded. kartik\grid\ExpandRowColumn
$expandTitle string Title to display on hover of expand indicator for each row. kartik\grid\ExpandRowColumn
$exportMenuHeaderStyle array Configuration for the \kartik\export\ExportMenu column header cell style that will be utilized by \PhpOffice\PhpSpreadsheet\Style\Style::applyFromArray(). kartik\grid\DataColumn
$exportMenuStyle array|Closure Configuration for the \kartik\export\ExportMenu column cell style that will be utilized by \PhpOffice\PhpSpreadsheet\Style\Style::applyFromArray(). kartik\grid\DataColumn
$extraData array Additional data that will be passed to the ajax load function as key value pairs kartik\grid\ExpandRowColumn
$filter string|array|null|false The HTML code representing a filter input (e.g. a text field, a dropdown list) that is used for this data column. yii\grid\DataColumn
$filterAttribute string|null The attribute name of the yii\grid\GridView::$filterModel associated with this column. yii\grid\DataColumn
$filterInputOptions array The HTML attributes for the filter input fields. yii\grid\DataColumn
$filterOptions array The HTML attributes for the filter cell tag. yii\grid\Column
$filterType string The filter input type for each filter input. kartik\grid\DataColumn
$filterWidgetOptions array The options/settings for the filter widget. kartik\grid\DataColumn
$footer string The footer cell content. yii\grid\Column
$footerOptions array The HTML attributes for the footer cell tag. yii\grid\Column
$format 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']). yii\grid\DataColumn
$grid yii\grid\GridView The grid view object that owns this column. yii\grid\Column
$group boolean Whether to group grid data by this column. kartik\grid\DataColumn
$groupEvenCssClass string|\kartik\grid\Closure, The even group css class. kartik\grid\DataColumn
$groupFooter array|Closure Configuration of the group footer which will be displayed as a separate row. kartik\grid\DataColumn
$groupHeader array|Closure Configuration of the group header which will be displayed as a separate row above the group. kartik\grid\DataColumn
$groupOddCssClass string|\kartik\grid\Closure, The odd group css class. kartik\grid\DataColumn
$groupedRow boolean|\kartik\grid\Closure, Whether to add a separate group row for grouping. kartik\grid\DataColumn
$hAlign string The horizontal alignment of each column. kartik\grid\ColumnTrait
$header string|null The header cell content. yii\grid\Column
$headerOptions array The HTML attributes for the header cell tag. yii\grid\Column
$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
$label string|null Label to be displayed in the header cell and also to be used as the sorting link label when sorting is enabled for this column. yii\grid\DataColumn
$mergeHeader boolean Whether to merge the header title row and the filter row. kartik\grid\ColumnTrait
$msgDetailLoading string The message to be shown while the detail content is loading or being rendered. kartik\grid\ExpandRowColumn
$noWrap boolean Whether to force no wrapping on all table cells in the column kartik\grid\ColumnTrait
$onDetailLoaded string|yii\web\JsExpression The javascript callback to execute after loading the content via ajax. kartik\grid\ExpandRowColumn
$options array The HTML attributes for the column group tag. yii\grid\Column
$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
$rowClickExcludedTags array List of tags in the row on which row click will be disabled. kartik\grid\ExpandRowColumn
$sortLinkOptions array The HTML attributes for the link tag in the header cell generated by yii\data\Sort::link() when sorting is enabled for this column. yii\grid\DataColumn
$stripTagsFromExport boolean Whether to strip HTML tags from the column during export. kartik\grid\ColumnTrait
$subGroupOf integer|Closure The column index of which this group is a sub group of. kartik\grid\DataColumn
$vAlign string The vertical alignment of each column. kartik\grid\ColumnTrait
$value integer|Closure The value of this attribute will identify the state of the current row. kartik\grid\ExpandRowColumn
$visible boolean Whether this column is visible. yii\grid\Column
$width string The width of each column (matches the CSS width property). kartik\grid\ColumnTrait
$xlFormat string The cell format for EXCEL exported content. kartik\grid\DataColumn

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$_clientScript string The internally generated client script to initialize kartik\grid\ColumnTrait
$_colId integer The current expand row column identifier kartik\grid\ExpandRowColumn
$_hashVar string Hashed javascript variable to store grid expand row options kartik\grid\ExpandRowColumn
$_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
__call() Calls the named method which is not a class method. yii\base\BaseObject
__construct() Constructor. 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() Returns the fully qualified name of this class. yii\base\BaseObject
getDataCellValue() Returns the data cell value. kartik\grid\ExpandRowColumn
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. kartik\grid\ExpandRowColumn
initColumnSettings() Initialize column settings kartik\grid\ColumnTrait
parseExcelFormats() Parses Excel Cell Formats for export kartik\grid\ColumnTrait
renderDataCell() Renders a data cell. kartik\grid\ExpandRowColumn
renderFilterCell() Renders the filter cell. kartik\grid\ColumnTrait
renderFooterCell() Renders the footer cell. yii\grid\Column
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
getHeaderCellLabel() Returns header cell label. yii\grid\DataColumn
getIcon() Get icon indicator kartik\grid\ExpandRowColumn
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
parseData() Parses data for Closure and returns accordingly kartik\grid\ExpandRowColumn
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
renderDataCellContent() Renders the data cell content. yii\grid\DataColumn
renderFilterCellContent() Renders filter inputs based on the filterType kartik\grid\DataColumn
renderFooterCellContent() Renders the footer cell content. yii\grid\Column
renderHeaderCellContent() Renders the header cell content. kartik\grid\ExpandRowColumn
renderPageSummaryCellContent() Renders the page summary cell content. kartik\grid\ColumnTrait
setPageRows() Store all rows for the column for the current page kartik\grid\ColumnTrait
setProp() Sets property for the object instance if not set kartik\grid\ExpandRowColumn

Property Details

$_colId protected property

The current expand row column identifier

protected integer $_colId null
$_hashVar protected property

Hashed javascript variable to store grid expand row options

protected string $_hashVar null
$allowBatchToggle public property

Allow batch expansion or batch collapse of all rows by clicking the header indicator. Defaults to true.

public boolean $allowBatchToggle true
$collapseAllTitle public property

Title to display on hover of collapse indicator at header.

public string $collapseAllTitle null
$collapseIcon public property

Icon for the collapse indicator. If this is not set, it will derive values automatically using the following rules:

  • If GridView bootstrap property is set to true, it will default to:
    • GridView::ICON_COLLAPSE for Bootstrap 3.x
    • GridView::ICON_COLLAPSE_BS4 for Bootstrap 4.x / 5.x
  • If GridView bootstrap property is set to false, then it will default to -.
public string $collapseIcon null
$collapseTitle public property

Title to display on hover of collapse indicator for each row.

public string $collapseTitle null
$defaultHeaderState public property

Default state of the header. The following values can be set:

  • GridView::ROW_COLLAPSED: Will set all rows to collapsed and display the $expandIcon.
  • GridView::ROW_EXPANDED: Will set all rows to expanded and display the $collapseIcon.
public integer $defaultHeaderState = \kartik\grid\GridView::ROW_COLLAPSED
$detail public property

The detail content (html markup) to be displayed in the expanded row. Either $detail or $detailUrl must be entered. This can be a normal html markup or an anonymous function that returns the markup. The anonymous function should have the signature: function ($model, $key, $index, $column), where:

  • $model: \yii\base\Model, is the data model.
  • $key: string|object, is the primary key value associated with the data model.
  • $index: integer, is the zero-based index of the data model among the model array returned by dataProvider.
  • $column: ExpandRowColumn, is the column object instance.
public string|Closure $detail ''
$detailAnimationDuration public property

The animation duration to slide up/down the detail row.

See also http://api.jquery.com/slidedown/.

$detailOptions public property

The HTML attributes for the expanded table row. This can be an array or an anonymous function of the signature: function ($model, $key, $index, $column), where:

  • $model: \yii\base\Model, is the data model.
  • $key: string|object, is the primary key value associated with the data model.
  • $index: integer, is the zero-based index of the data model among the model array returned by dataProvider.
  • $column: ExpandRowColumn, is the column object instance.
$detailRowCssClass public property

The CSS class for the detail content table row.

public string $detailRowCssClass null
$detailUrl public property

The url/action that would render the detail content via ajax. Either detail OR detailUrl must be entered. The ajax response must return the content/markup to render. The extension automatically passes the following data parameters to the server URL as POST data:

  • expandRowKey the key associated with the data model
  • expandRowIndex the zero-based index of the data model among the models array returned by kartik\grid\GridView::$dataProvider.

See also http://api.jquery.com/jquery.load/.

public string $detailUrl null
$disabled public property

Whether the expand icon indicator is disabled. Defaults to false. If set to true, one cannot collapse or expand the sections. This can be setup as an anonymous function having the signature: function ($model, $key, $index, $column), where:

  • $model: \yii\base\Model, is the data model.
  • $key: string|object, is the primary key value associated with the data model.
  • $index: integer, is the zero-based index of the data model among the model array returned by dataProvider.
  • $column: ExpandRowColumn, is the column object instance.
public boolean|Closure $disabled false
$enableCache public property

Whether to enable caching of expanded row content while expanding the row using ajax triggered action (applicable when detailUrl is set). Defaults to true.

public boolean $enableCache true
$enableRowClick public property

Whether to toggle the expansion/collapse by clicking on the table row. To disable row click for specific elements within the row you can add the CSS class kv-disable-click to tags/elements to disable the toggle functionality.

public boolean $enableRowClick false
$expandAllTitle public property

Title to display on hover of expand indicator at header.

public string $expandAllTitle null
$expandIcon public property

Icon for the expand indicator. If this is not set, it will derive values automatically using the following rules:

  • If GridView bootstrap property is set to true, it will default to:
    • GridView::ICON_EXPAND for Bootstrap 3.x
    • GridView::ICON_EXPAND_BS4 for Bootstrap 4.x / 5.x
  • If GridView bootstrap property is set to false, then it will default to +.
public string $expandIcon null
$expandOneOnly public property

Whether to allow only one row to be expanded at a time and auto collapse other expanded rows whenever a row is expanded. Defaults to false.

public boolean $expandOneOnly false
$expandTitle public property

Title to display on hover of expand indicator for each row.

public string $expandTitle null
$extraData public property

Additional data that will be passed to the ajax load function as key value pairs

public array $extraData = []
$msgDetailLoading public property

The message to be shown while the detail content is loading or being rendered. Defaults to <small>Loading &hellip;</small>

public string $msgDetailLoading null
$onDetailLoaded public property

The javascript callback to execute after loading the content via ajax. Only applicable when detailUrl is provided.

$rowClickExcludedTags public property

List of tags in the row on which row click will be disabled.

public array $rowClickExcludedTags = [
    'a''button''input'
]
$value public property

The value of this attribute will identify the state of the current row. The following values are supported:

  • GridView::ROW_EXPANDED or 0: the row will be expanded by default and will display the collapse indicator.
  • GridView::ROW_COLLAPSED or 1: the row will be collapsed by default and will display the expand indicator.
  • GridView::ROW_NONE or -1: no indicator will be displayed for the row.

If this is not set, $model[$attribute] will be used to obtain the value. If this value is evaluated as empty or null, it is treated as GridView::ROW_NONE. This can also be an anonymous function that returns one of the values above. The anonymous function should have the signature function ($model, $key, $index, $column), where:

  • $model: \yii\base\Model, is the data model.
  • $key: string|object, is the primary key value associated with the data model.
  • $index: integer, is the zero-based index of the data model among the model array returned by dataProvider.
  • $column: ExpandRowColumn, is the column object instance.
public integer|Closure $value = \kartik\grid\GridView::ROW_NONE

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

The zero-based index of the data model among the models array returned by kartik\grid\GridView::$dataProvider.

return string

The data cell value

getIcon() protected method

Get icon indicator

protected string getIcon ( $type )
$type string

One of expand or collapse

return string

The icon indicator markup

throws \yii\base\InvalidConfigException|\Exception
init() public method

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

public void init ( )
throws yii\base\InvalidConfigException
parseData() protected static method

Parses data for Closure and returns accordingly

protected static mixed parseData ( $data, $model, $key, $index, $column )
$data string|Closure

The data to parse.

$model yii\base\Model

The data model.

$key string|object

The key associated with the data model.

$index integer

The zero-based index of the data model among the models array returned by kartik\grid\GridView::$dataProvider.

$column kartik\grid\ExpandRowColumn

The column object instance.

renderDataCell() public method

Renders a data cell.

public string renderDataCell ( $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.

return string

The rendering result

renderHeaderCellContent() protected 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.

protected string renderHeaderCellContent ( )
return string

The rendering result

setProp() protected method

Sets property for the object instance if not set

protected void setProp ( $prop, $val )
$prop string

The property name

$val string

The property value