Skip to content

CheckboxHeader

See the Checkbox cell type guide for examples and configuration details.

Options

headerCheckbox

Can be set at: grid columns

Source code

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:

SettingDescription
false or unset (default)No header checkbox
trueA 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

Source code

CheckboxHeader.LICENSE

Returns the license token of the plugin, its display name, where it is checked, and the tokens it requires.

PLUGIN_DEPS

Source code

CheckboxHeader.PLUGIN_DEPS

Returns the list of plugin dependencies required before this plugin can be initialized.

PLUGIN_KEY

Source code

CheckboxHeader.PLUGIN_KEY

Returns the plugin key used to identify this plugin in Handsontable settings.

PLUGIN_PRIORITY

Source code

CheckboxHeader.PLUGIN_PRIORITY

Returns the priority order used to determine the order in which plugins are initialized.

SETTING_KEYS

Source code

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

Source code

checkboxHeader.destroy()

Destroys the plugin instance.

disablePlugin

Source code

checkboxHeader.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin

Source code

checkboxHeader.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getHeaderCheckboxState

Source code

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.

ParamTypeDescription
columnnumberVisual column index.

hasHeaderCheckbox

Source code

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).

ParamTypeDescription
columnnumberVisual column index.

isEnabled

Source code

checkboxHeader.isEnabled() ⇒ boolean

Checks if the plugin is enabled. It always is: a column opts in through its own headerCheckbox option.

onGridReady

Source code

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

Source code

checkboxHeader.setColumnChecked(column, checked) ⇒ boolean

Checks or unchecks every editable checkbox in the column’s scope. It is one undo step.

ParamTypeDescription
columnnumberVisual column index.
checkedbooleantrue to check, false to uncheck.

Returns: boolean - true if any value changed.

toggleColumn

Source code

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.

ParamTypeDescription
columnnumberVisual column index.

Returns: boolean - true if any value changed.