Skip to content

NestedHeaders

Options

nestedHeaders

Source code

nestedHeaders.nestedHeaders : boolean | Array<Array>

The nestedHeaders option configures the NestedHeaders plugin.

You can set the nestedHeaders option to one of the following:

SettingDescription
false (default)Disable the NestedHeaders plugin
true- Enable the NestedHeaders plugin
- Don’t configure any nested headers
Array of arrays- Enable the NestedHeaders plugin
- Configure headers that are nested on Handsontable’s initialization

If you set the nestedHeaders option to an array of arrays, each array configures one row of nested headers (top row first). Within a row, headers are listed left to right.

Each array element configures one header, and can be one of the following:

Array elementDescription
A stringThe header’s label
An objectA header configuration object (see the properties below)

A header configuration object accepts the following properties:

PropertyTypeDescription
labelstringThe header’s label.
colspannumberThe number of data columns the header spans (an integer greater than 1). Groups the columns it covers.
rowspannumberThe number of header rows the header spans (an integer greater than 1).
headerClassNamestringOne or more space-separated CSS class names added to the header element (for example, 'htRight').
visibleWhenstringFor a header inside a collapsible group, sets in which collapse state the header (and its columns) stays visible: 'collapsed' (visible only while the group is collapsed), 'expanded' (visible only while the group is expanded), or 'always' (visible in both states). When omitted, a header in such a group defaults to 'expanded' - it is hidden when the group collapses. At least one column of a group always stays visible.
columnDropModestringControls what a group does when a column move (with the ManualColumnMove plugin) drops a foreign column (one belonging to another group) into its span. With 'adopt' (default), the group adopts that column as a child and stays one banner. With 'split', the group keeps its identity and renders as several same-label banners around the foreign column (it splits). A group always reclaims its own columns when they move back into its span, regardless of this setting. Meaningful only on a header that spans columns.

Read more:

This option can only be set at the grid level. It has no effect when set in the columns, cells, or cell options.

Default: undefined
Example

// group headers with `label` and `colspan`
nestedHeaders: [
['A', {label: 'B', colspan: 8}, 'C'],
['D', {label: 'E', colspan: 4}, {label: 'F', colspan: 4}, 'G'],
['H', 'I', 'J', 'K', 'L', 'M', 'N', 'R', 'S', 'T']
],
// choose which columns stay visible when a collapsible group is collapsed:
// unmarked headers (Jan, Feb, Mar) are hidden on collapse; `Total` appears only when collapsed
nestedHeaders: [
['Region', {label: 'Q1 2025', colspan: 4}],
['Region', 'Jan', 'Feb', 'Mar', {label: 'Total', visibleWhen: 'collapsed'}]
],
collapsibleColumns: true,

Members

detectedOverlappedHeaders

Source code

nestedHeaders.detectedOverlappedHeaders

The flag which determines that the nested header settings contains overlapping headers configuration.

ghostTable

Source code

nestedHeaders.ghostTable

Custom helper for getting widths of the nested headers.

PLUGIN_KEY

Source code

NestedHeaders.PLUGIN_KEY

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

PLUGIN_PRIORITY

Source code

NestedHeaders.PLUGIN_PRIORITY

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

Methods

_getHeaderTreeNodeDataByCoords

Source code

nestedHeaders._getHeaderTreeNodeDataByCoords()

Returns the header tree node data for the given coordinates, or undefined if the coordinates do not point to a header cell.

clearColspans

Source code

nestedHeaders.clearColspans()

Removes all colspan and rowspan attributes from the rendered header cells in all overlays.

destroy

Source code

nestedHeaders.destroy()

Destroys the plugin instance.

disablePlugin

Source code

nestedHeaders.disablePlugin()

Disables the plugin by removing all registered hooks, clearing header state, and resetting visual indicators.

enablePlugin

Source code

nestedHeaders.enablePlugin()

Enables the plugin by registering all required hooks and initializing the header state.

getColumnHeaderValue

Source code

nestedHeaders.getColumnHeaderValue()

Returns the display value for a nested header cell at the given visual column index and header level.

getHeaderSettings

Source code

nestedHeaders.getHeaderSettings()

Returns the header settings node for the specified header level and column index.

getLayersCount

Source code

nestedHeaders.getLayersCount()

Returns the number of nested header rows currently configured in the plugin.

getStateManager

Source code

nestedHeaders.getStateManager()

Returns the internal state manager that tracks the nested header spans and their layout configuration.

headerRendererFactory

Source code

nestedHeaders.headerRendererFactory()

Creates and returns a header renderer function for the specified header layer level.

isEnabled

Source code

nestedHeaders.isEnabled()

Returns whether the plugin is enabled based on the presence of the nestedHeaders settings key.

updatePlugin

Source code

nestedHeaders.updatePlugin()

Updates the plugin state when Handsontable settings change, rebuilding the header tree and refreshing column widths.