Skip to content

EditableHeaders

See the Column headers guide for examples and configuration details.

Options

editableHeaders

Can be set at: grid columns

Source code

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:

SettingDescription
trueEnable the EditableHeaders plugin for column headers
falseDisable the EditableHeaders plugin
An objectEnable the EditableHeaders plugin and choose the header axes

The object form accepts the following properties:

PropertyTypeDefaultDescription
columnHeadersbooleantrueWhether users can rename column headers
rowHeadersbooleanfalseWhether 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 headers
editableHeaders: true,
// let users rename column headers and row headers
editableHeaders: {
columnHeaders: true,
rowHeaders: true,
},
// keep the first column's header from being renamed
columns: [
{ editableHeaders: false },
{},
],

Members

DEFAULT_SETTINGS

Source code

EditableHeaders.DEFAULT_SETTINGS ⇒ object

The defaults of the object form of the plugin’s settings.

LICENSE

Source code

EditableHeaders.LICENSE ⇒ object

The plugin’s license token.

PLUGIN_KEY

Source code

EditableHeaders.PLUGIN_KEY ⇒ string

The plugin’s key in the settings.

PLUGIN_PRIORITY

Source code

EditableHeaders.PLUGIN_PRIORITY ⇒ number

The plugin’s enable order.

SETTING_KEYS

Source code

EditableHeaders.SETTING_KEYS ⇒ Array<string>

The settings keys that reach updatePlugin(): the plugin’s own, and nestedHeaders, which turns column renaming off.

SETTINGS_VALIDATORS

Source code

EditableHeaders.SETTINGS_VALIDATORS ⇒ object

The validators of the object form of the plugin’s settings.

Methods

clearHeaders

Source code

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.

ParamTypeDescription
[axis]stringoptional 'column' or 'row'. Both when left out.

closeEditor

Source code

editableHeaders.closeEditor([save])

Closes the input, if open.

ParamTypeDefaultDescription
[save]booleantrueoptional true to rename the header to the text in the input, false to cancel.

destroy

Source code

editableHeaders.destroy()

Destroys the plugin instance.

disablePlugin

Source code

editableHeaders.disablePlugin()

Disables the plugin functionality for this Handsontable instance. The renamed headers are dropped.

enablePlugin

Source code

editableHeaders.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getHeader

Source code

editableHeaders.getHeader(axis, visualIndex) ⇒ string | undefined

Returns the name a user gave a header, or undefined when the header was not renamed.

ParamTypeDescription
axisstring'column' for a column header, 'row' for a row header.
visualIndexnumberThe visual index of the column or row.

isEditable

Source code

editableHeaders.isEditable(axis, visualIndex) ⇒ boolean

Checks whether users can rename a header.

ParamTypeDescription
axisstring'column' for a column header, 'row' for a row header.
visualIndexnumberThe visual index of the column or row.

isEditorOpened

Source code

editableHeaders.isEditorOpened() ⇒ boolean

Checks whether the input is open.

isEnabled

Source code

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

Source code

editableHeaders.openEditor(axis, visualIndex) ⇒ boolean

Opens the input over a header, scrolling the header into view first.

ParamTypeDescription
axisstring'column' for a column header, 'row' for a row header.
visualIndexnumberThe visual index of the column or row.

Returns: boolean - true when the input opened.

setHeader

Source code

editableHeaders.setHeader(axis, visualIndex, value) ⇒ boolean

Renames a header, as one undo step. Fires Hooks#beforeHeaderChange, which can cancel the change, and Hooks#afterHeaderChange.

ParamTypeDescription
axisstring'column' for a column header, 'row' for a row header.
visualIndexnumberThe visual index of the column or row.
valuestringThe new header name. Stored as text.

Returns: boolean - true when the header was renamed.

updatePlugin

Source code

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.