Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CheckboxColumn

CheckboxColumn displays a column of checkboxes in a grid view.

To add a CheckboxColumn to the GridView, add it to the columns configuration as follows:

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

Users may click on the checkboxes to select rows of the grid. The selected rows may be obtained by calling the following JavaScript code:

var keys = $('#grid').yiiGridView('getSelectedRows');
// keys is an array consisting of the keys associated with the selected rows

For more details and usage information on CheckboxColumn, see the guide article on data widgets.

Hierarchy

Index

Constructors

Properties

checkboxOptions: {} = {}

Closure the HTML attributes for checkboxes. 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). 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 CheckboxColumn object. A function may be used to assign different attributes to different rows based on the data in that row. Specifically if you want to set a different value for the checkbox you can use this option in the following way (in this example using the name attribute of the model):

checkboxOptions: function (model, key, index, column) {
return {value: model.name};
}
see

Html.renderTagAttributes for details on how attributes are being rendered.

Type declaration

  • [key: string]: any
content: string | CallableFunction

This is a callable that will be used to generate the content of each cell. The signature of the function should be the following: 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 Column object.

contentOptions: {} = {}

Closure 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). 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 Column object. A function may be used to assign different attributes to different rows based on the data in that row.

see

Html.renderTagAttributes for details on how attributes are being rendered.

Type declaration

  • [key: string]: any
cssClass: string

The css class that will be used to find the checkboxes.

filterOptions: {} = {}

The HTML attributes for the filter cell tag.

see

Html.renderTagAttributes for details on how attributes are being rendered.

Type declaration

  • [key: string]: any
footer: string

The footer cell content. Note that it will not be HTML-encoded.

footerOptions: {} = {}

The HTML attributes for the footer cell tag.

see

Html.renderTagAttributes for details on how attributes are being rendered.

Type declaration

  • [key: string]: any
grid: GridView

The grid view object that owns this column.

header: string

The header cell content. Note that it will not be HTML-encoded.

headerOptions: {} = {}

The HTML attributes for the header cell tag.

see

Html.renderTagAttributes for details on how attributes are being rendered.

Type declaration

  • [key: string]: any
initialization: Promise<void>

A Promise which resolves when this Component has been successfully initialized.

multiple: boolean = true

Whether it is possible to select multiple rows. Defaults to true.

name: string = 'selection'

The name of the input checkbox input fields. This will be appended with [] to ensure it is an array.

options: {} = {}

The HTML attributes for the column group tag.

see

Html.renderTagAttributes for details on how attributes are being rendered.

Type declaration

  • [key: string]: any
visible: boolean = true

Whether this column is visible. Defaults to true.

Methods

  • getHeaderCellLabel(): Promise<string>
  • getHeaderCheckBoxName(): string
  • init(): Promise<void>
  • registerClientScript(): void
  • renderDataCell(model: Model, key: string, index: number): Promise<string>
  • Renders a data cell.

    Parameters

    • model: Model

      the data model being rendered

    • key: string

      the key associated with the data model

    • index: number

      the zero-based index of the data item among the item array returned by GridView.dataProvider.

    Returns Promise<string>

    the rendering result

  • renderDataCellContent(model: Model, key: string, index: number): Promise<string>
  • renderFilterCell(): string
  • renderFilterCellContent(): string
  • Renders the filter cell content. The default implementation simply renders a space. This method may be overridden to customize the rendering of the filter cell (if any).

    Returns string

    the rendering result

  • renderFooterCell(): string
  • renderFooterCellContent(): string
  • Renders the footer cell content. The default implementation simply renders footer. This method may be overridden to customize the rendering of the footer cell.

    Returns string

    the rendering result

  • renderHeaderCell(): Promise<string>
  • renderHeaderCellContent(): Promise<string>

Generated using TypeDoc