CheckboxHeader
See the Checkbox cell type guide for examples and configuration details.
Options
headerCheckbox
Can be set at: grid columns
checkboxHeader.headerCheckbox : boolean | object
The headerCheckbox option adds a “check all” checkbox to the header of a
checkbox column. A click on it checks every
checkbox in the column, or unchecks them when all of them are checked, and writes the values into
the data in one undo step. When only some cells are checked, the header checkbox shows the mixed
state. Read-only cells are skipped.
You can set the headerCheckbox option to one of the following:
| Setting | Description |
|---|---|
false or unset (default) | No header checkbox |
true | A header checkbox that writes to the rows that pass the filters (all pages) |
{ scope: 'filtered' } | The same as true |
{ scope: 'all' } | Also writes to the rows the filters hide |
{ scope: 'currentPage' } | Writes only to the rows on the current page of the Pagination plugin |
The option works only on columns whose type is 'checkbox'. Rows hidden with the
HiddenRows plugin and rows trimmed with the TrimRows
plugin are never written.
Read more:
Default: undefined
Since: 19.0.0
Example
columns: [ { data: 'name' }, // a "check all" checkbox in the header of the `active` column { data: 'active', type: 'checkbox', headerCheckbox: true },],Members
LICENSE
CheckboxHeader.LICENSE
Returns the license token of the plugin, its display name, where it is checked, and the tokens it requires.
PLUGIN_DEPS
CheckboxHeader.PLUGIN_DEPS
Returns the list of plugin dependencies required before this plugin can be initialized.
PLUGIN_KEY
CheckboxHeader.PLUGIN_KEY
Returns the plugin key used to identify this plugin in Handsontable settings.
PLUGIN_PRIORITY
CheckboxHeader.PLUGIN_PRIORITY
Returns the priority order used to determine the order in which plugins are initialized.
SETTING_KEYS
CheckboxHeader.SETTING_KEYS
The plugin reacts to the column-level headerCheckbox option, which no grid-level key carries,
so no settings update needs to reach updatePlugin().
Methods
destroy
checkboxHeader.destroy()
Destroys the plugin instance.
disablePlugin
checkboxHeader.disablePlugin()
Disables the plugin functionality for this Handsontable instance.
enablePlugin
checkboxHeader.enablePlugin()
Enables the plugin functionality for this Handsontable instance.
getHeaderCheckboxState
checkboxHeader.getHeaderCheckboxState(column) ⇒ Object
Returns the state of a column’s “check all” checkbox: 'checked', 'unchecked', 'mixed', or
'disabled' (no editable checkbox in the scope), with the number of checked and editable cells.
| Param | Type | Description |
|---|---|---|
| column | number | Visual column index. |
hasHeaderCheckbox
checkboxHeader.hasHeaderCheckbox(column) ⇒ boolean
Tells whether the column shows a “check all” checkbox: it is a checkbox column with the
headerCheckbox option, and the RowSelection plugin does not render
its checkboxes in it (its bound column, or the first column with checkboxLocation: 'firstColumn';
then that plugin owns the header).
| Param | Type | Description |
|---|---|---|
| column | number | Visual column index. |
isEnabled
checkboxHeader.isEnabled() ⇒ boolean
Checks if the plugin is enabled. It always is: a column opts in through its own
headerCheckbox option.
onGridReady
checkboxHeader.onGridReady()
Reports the header checkboxes the license key does not cover before the grid’s first render, so the license message the grid writes then names them.
setColumnChecked
checkboxHeader.setColumnChecked(column, checked) ⇒ boolean
Checks or unchecks every editable checkbox in the column’s scope. It is one undo step.
| Param | Type | Description |
|---|---|---|
| column | number | Visual column index. |
| checked | boolean | true to check, false to uncheck. |
Returns: boolean - true if any value changed.
toggleColumn
checkboxHeader.toggleColumn(column) ⇒ boolean
Checks every editable checkbox in the column’s scope, or unchecks them when all are checked, the way a click on the “check all” checkbox does. It is one undo step.
| Param | Type | Description |
|---|---|---|
| column | number | Visual column index. |
Returns: boolean - true if any value changed.