Class kartik\grid\ActionColumn
Inheritance | kartik\grid\ActionColumn » yii\grid\ActionColumn » yii\grid\Column » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable |
Uses Traits | kartik\grid\ColumnTrait |
Available since version | 1.0 |
The ActionColumn is a column that displays buttons for viewing and manipulating the items and extends the yii\grid\ActionColumn with various enhancements.
To add an ActionColumn to the gridview, add it to the columns configuration as follows:
'columns' => [
// ...
[
'class' => ActionColumn::class,
// you may configure additional properties here
],
]
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$buttonOptions | array | Html options to be applied to the default button. | yii\grid\ActionColumn |
$buttons | array | Button rendering callbacks. | yii\grid\ActionColumn |
$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. | kartik\grid\ActionColumn |
$controller | string|null | The ID of the controller that should handle the actions specified here. | yii\grid\ActionColumn |
$deleteOptions | array | HTML attributes for the delete action button. | kartik\grid\ActionColumn |
$dropdown | boolean | Whether the action buttons are to be displayed as a dropdown | kartik\grid\ActionColumn |
$dropdownButton | array|Closure | The dropdown button options. | kartik\grid\ActionColumn |
$dropdownMenu | array | The HTML attributes for the Dropdown menu. | kartik\grid\ActionColumn |
$dropdownOptions | array | The HTML attributes for the Dropdown container. | kartik\grid\ActionColumn |
$filterOptions | array | The HTML attributes for the filter cell tag. | yii\grid\Column |
$footer | string | The footer cell content. | yii\grid\Column |
$footerOptions | array | The HTML attributes for the footer cell tag. | yii\grid\Column |
$grid | yii\grid\GridView | The grid view object that owns this column. | yii\grid\Column |
$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. | kartik\grid\ActionColumn |
$hidePageSummary | boolean | Whether to just hide the page summary display but still calculate the summary based on $pageSummary settings | kartik\grid\ColumnTrait |
$icons | array | Button icons. | yii\grid\ActionColumn |
$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 |
$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 |
$stripTagsFromExport | boolean | Whether to strip HTML tags from the column during export. | kartik\grid\ColumnTrait |
$template | string | The template used for composing each cell in the action column. | yii\grid\ActionColumn |
$updateOptions | array | HTML attributes for the update action button. | kartik\grid\ActionColumn |
$urlCreator | callable|null | A callback that creates a button URL using the specified model information. | yii\grid\ActionColumn |
$vAlign | string | The vertical alignment of each column. | kartik\grid\ColumnTrait |
$viewOptions | array | HTML attributes for the view action button. | kartik\grid\ActionColumn |
$visible | boolean | Whether this column is visible. | yii\grid\Column |
$visibleButtons | array | Visibility conditions for each button. | yii\grid\ActionColumn |
$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 |
$_isDropdown | boolean | Is the dropdown menu to be rendered? | kartik\grid\ActionColumn |
$_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 |
---|---|---|
__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 |
createUrl() | Creates a URL for the given action and model. | yii\grid\ActionColumn |
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\ActionColumn |
initColumnSettings() | Initialize column settings | kartik\grid\ColumnTrait |
parseExcelFormats() | Parses Excel Cell Formats for export | kartik\grid\ColumnTrait |
renderDataCell() | Renders a data cell. | kartik\grid\ActionColumn |
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
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 |
getHeaderCellLabel() | Returns header cell label. | yii\grid\Column |
getPageSummaryCellContent() | Gets the raw page summary cell content. | kartik\grid\ColumnTrait |
initColumnKey() | Initializes the column key | kartik\grid\ColumnTrait |
initDefaultButton() | Initializes the default button rendering callback for single button. | yii\grid\ActionColumn |
initDefaultButtons() | Initializes the default button rendering callbacks. | kartik\grid\ActionColumn |
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 |
renderDataCellContent() | Renders the data cell content. | kartik\grid\ActionColumn |
renderFilterCellContent() | Renders the filter cell content. | yii\grid\Column |
renderFooterCellContent() | Renders the footer cell content. | yii\grid\Column |
renderHeaderCellContent() | Renders the header cell content. | yii\grid\Column |
renderIcon() | Renders button icon | kartik\grid\ActionColumn |
renderLabel() | Renders button label | kartik\grid\ActionColumn |
renderPageSummaryCellContent() | Renders the page summary cell content. | kartik\grid\ColumnTrait |
setDefaultButton() | Sets a default button configuration based on the button name. | kartik\grid\ActionColumn |
setPageRows() | Store all rows for the column for the current page | kartik\grid\ColumnTrait |
Property Details
Is the dropdown menu to be rendered?
The HTML attributes for the data cell tag. This can either be an array of attributes or an
anonymous function (Closure) that returns such an array. The signature of the function should be the
following: function ($model, $key, $index, $column)
. A function may be used to assign different attributes
to different rows based on the data in that row.
See also yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
HTML attributes for the delete action button. The following additional options are recognized:
label
: string, the label for the delete action button. This is not html encoded. Defaults toDelete
.icon
: null|array|string the icon HTML attributes as an array or the raw icon markup as string or false to disable the icon and just use text label instead. When set as a string, this is not HTML encoded. If null or not set, the default icon with CSSglyphicon glyphicon-trash
will be displayed as the icon for the default button.data-method
: string, the delete HTTP method. Defaults topost
.data-confirm
: string, the delete confirmation message to display when the delete button is clicked. Defaults toAre you sure to delete this {item}?
, where the{item}
token will be replaced with theGridView::itemLabelSingle
property.
Whether the action buttons are to be displayed as a dropdown
The dropdown button options. This configuration will be applicable only if $dropdown is
true
. When set as an array, the following special options are recognized:
label
: string', the button label to be displayed. Defaults toActions
.caret
: string', the caret symbol to be appended to the dropdown button. Applicable only for Bootstrap 3.x versions whenGridView::bsVersion = 3.x
. Defaults to<span class="caret"></span>
.
This can also be setup as a Closure
callback function of the following signature that returns the above array:
function ($model, $key, $index) {}
, where:
$model
: \yii\db\ActiveRecordInterface is the data model of current row$key
: mixed, is the key associated with the data model$index
: int, is the current row index
The HTML attributes for the Dropdown menu. Applicable if dropdown
is true
. To align a
dropdown at the right edge of the page container, you set the class to dropdown-menu-right
for Bootstrap v4.x.
The HTML attributes for the Dropdown container. The class dropdown
will be added. To align a
dropdown at the right edge of the page container, you set the class to pull-right
for Bootstrap v3.x and
for Bootstrap v4.x add dropdown-menu-right
class in $dropdownMenu.
The HTML attributes for the header cell tag.
See also yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
HTML attributes for the update action button. The following additional options are recognized:
label
: string, the label for the update action button. This is not html encoded. Defaults toUpdate
.icon
: null|array|string the icon HTML attributes as an array or the raw icon markup as string or false to disable the icon and just use text label instead. When set as a string, this is not HTML encoded. If null or not set, the default icon with CSSglyphicon glyphicon-pencil
will be displayed as the icon for the default button.
HTML attributes for the view action button. The following additional options are recognized:
label
: string, the label for the view action button. This is not html encoded. Defaults toView
.icon
: null|array|string the icon HTML attributes as an array or the raw icon markup as string or false to disable the icon and just use text label instead. When set as a string, this is not HTML encoded. If null or not set, the default icon with CSSglyphicon glyphicon-eye-open
will be displayed as the icon for the default button.
Method Details
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 |
---|
Initializes the default button rendering callbacks.
protected void initDefaultButtons ( ) | ||
throws | yii\base\InvalidConfigException |
---|
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 |
---|---|---|
throws | yii\base\InvalidConfigException |
Renders the data cell content.
protected string renderDataCellContent ( $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 rendering result |
---|---|---|
throws | yii\base\InvalidConfigException |
Renders button icon
protected string renderIcon ( &$options, $iconOptions = [] ) | ||
$options | array | HTML attributes for the action button element |
$iconOptions | array | HTML attributes for the icon element. The following additional options are recognized:
|
Renders button label
protected string renderLabel ( &$options, $title, $iconOptions = [] ) | ||
$options | array | HTML attributes for the action button element |
$title | string | The action button title |
$iconOptions | array | HTML attributes for the icon element (see renderIcon()) |
Sets a default button configuration based on the button name.
protected void setDefaultButton ( $name, $title, $icon ) | ||
$name | string | Button name as written in the $template |
$title | string | The title of the button |
$icon | string | The meaningful icon suffix name for the button |
throws | \yii\base\InvalidConfigException|\Exception |
---|