EditableHeaders
See the Column headers guide for examples and configuration details.
Options
editableHeaders
Can be set at: grid columns
editableHeaders.editableHeaders : boolean | object
The editableHeaders option configures the EditableHeaders plugin, which lets
users rename column headers, and optionally row headers, the way they edit cells.
You can set the editableHeaders option to one of the following:
| Setting | Description |
|---|---|
true | Enable the EditableHeaders plugin for column headers |
false | Disable the EditableHeaders plugin |
| An object | Enable the EditableHeaders plugin and choose the header axes |
The object form accepts the following properties:
| Property | Type | Default | Description |
|---|---|---|---|
columnHeaders | boolean | true | Whether users can rename column headers |
rowHeaders | boolean | false | Whether users can rename row headers |
To keep one column’s header from being renamed, set editableHeaders: false for that column in the
columns option.
Read more:
Default: undefined
Since: 19.0.0
Example
// let users rename column headerseditableHeaders: true,
// let users rename column headers and row headerseditableHeaders: { columnHeaders: true, rowHeaders: true,},
// keep the first column's header from being renamedcolumns: [ { editableHeaders: false }, {},],Members
DEFAULT_SETTINGS
EditableHeaders.DEFAULT_SETTINGS ⇒ object
The defaults of the object form of the plugin’s settings.
LICENSE
EditableHeaders.LICENSE ⇒ object
The plugin’s license token.
PLUGIN_KEY
EditableHeaders.PLUGIN_KEY ⇒ string
The plugin’s key in the settings.
PLUGIN_PRIORITY
EditableHeaders.PLUGIN_PRIORITY ⇒ number
The plugin’s enable order.
SETTING_KEYS
EditableHeaders.SETTING_KEYS ⇒ Array<string>
The settings keys that reach updatePlugin(): the plugin’s own, and nestedHeaders, which turns column
renaming off.
SETTINGS_VALIDATORS
EditableHeaders.SETTINGS_VALIDATORS ⇒ object
The validators of the object form of the plugin’s settings.
Methods
clearHeaders
editableHeaders.clearHeaders([axis])
Drops the names users gave headers, so the headers show the configured values again. One undo step. Fires Hooks#afterHeaderChange for every header it changes, and never Hooks#beforeHeaderChange.
| Param | Type | Description |
|---|---|---|
| [axis] | string | optional 'column' or 'row'. Both when left out. |
closeEditor
editableHeaders.closeEditor([save])
Closes the input, if open.
| Param | Type | Default | Description |
|---|---|---|---|
| [save] | boolean | true | optional true to rename the header to the text in the input, false to cancel. |
destroy
editableHeaders.destroy()
Destroys the plugin instance.
disablePlugin
editableHeaders.disablePlugin()
Disables the plugin functionality for this Handsontable instance. The renamed headers are dropped.
enablePlugin
editableHeaders.enablePlugin()
Enables the plugin functionality for this Handsontable instance.
getHeader
editableHeaders.getHeader(axis, visualIndex) ⇒ string | undefined
Returns the name a user gave a header, or undefined when the header was not renamed.
| Param | Type | Description |
|---|---|---|
| axis | string | 'column' for a column header, 'row' for a row header. |
| visualIndex | number | The visual index of the column or row. |
isEditable
editableHeaders.isEditable(axis, visualIndex) ⇒ boolean
Checks whether users can rename a header.
| Param | Type | Description |
|---|---|---|
| axis | string | 'column' for a column header, 'row' for a row header. |
| visualIndex | number | The visual index of the column or row. |
isEditorOpened
editableHeaders.isEditorOpened() ⇒ boolean
Checks whether the input is open.
isEnabled
editableHeaders.isEnabled() ⇒ boolean
Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit
hook and if it returns true then the EditableHeaders#enablePlugin method is called.
openEditor
editableHeaders.openEditor(axis, visualIndex) ⇒ boolean
Opens the input over a header, scrolling the header into view first.
| Param | Type | Description |
|---|---|---|
| axis | string | 'column' for a column header, 'row' for a row header. |
| visualIndex | number | The visual index of the column or row. |
Returns: boolean - true when the input opened.
setHeader
editableHeaders.setHeader(axis, visualIndex, value) ⇒ boolean
Renames a header, as one undo step. Fires Hooks#beforeHeaderChange, which can cancel the change, and Hooks#afterHeaderChange.
| Param | Type | Description |
|---|---|---|
| axis | string | 'column' for a column header, 'row' for a row header. |
| visualIndex | number | The visual index of the column or row. |
| value | string | The new header name. Stored as text. |
Returns: boolean - true when the header was renamed.
updatePlugin
editableHeaders.updatePlugin()
Updates the plugin’s state.
This method is executed when updateSettings() is invoked with any of the
following configuration options:
The renamed headers are kept, and so is an open input whose header can still be renamed: the framework wrappers send the options again on a render.