Skip to content

NestedRows

Options

nestedRows

Source code

nestedRows.nestedRows : boolean

The nestedRows option configures the NestedRows plugin.

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

SettingDescription
false (default)Disable the NestedRows plugin
trueEnable the NestedRows plugin

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: false
Example

// enable the `NestedRows` plugin
nestedRows: true,

Members

PLUGIN_KEY

Source code

NestedRows.PLUGIN_KEY

Returns the plugin key used to identify and access this plugin within Handsontable.

PLUGIN_PRIORITY

Source code

NestedRows.PLUGIN_PRIORITY

Returns the priority value that determines the plugin’s initialization order relative to other plugins.

Methods

collapseAll

Source code

nestedRows.collapseAll()

Collapses every top-level parent row, which hides all of their descendants.

A parent that was already collapsed inside another one stays collapsed.

Emits: Hooks#event:beforeRowCollapse, Hooks#event:afterRowCollapse

collapseParent

Source code

nestedRows.collapseParent(row) ⇒ boolean

Collapses a parent row, which hides its children.

Emits: Hooks#event:beforeRowCollapse, Hooks#event:afterRowCollapse

ParamTypeDescription
rownumberVisual row index of the parent.

Returns: boolean - true if the collapsed state changed. false when the row is not a parent, when it is already collapsed, or when the Hooks#beforeRowCollapse hook blocked the action.

countChildren

Source code

nestedRows.countChildren(row, [recursive]) ⇒ number

Counts the children of a row.

ParamTypeDefaultDescription
rownumberVisual row index.
[recursive]booleanfalseoptional true counts every descendant, false counts only the direct children.

destroy

Source code

nestedRows.destroy()

Destroys the plugin instance.

disablePlugin

Source code

nestedRows.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin

Source code

nestedRows.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

expandAll

Source code

nestedRows.expandAll()

Expands every collapsed parent row at every nesting level, so no row stays hidden.

Emits: Hooks#event:beforeRowExpand, Hooks#event:afterRowExpand

expandParent

Source code

nestedRows.expandParent(row) ⇒ boolean

Expands a parent row, which shows its children again.

Emits: Hooks#event:beforeRowExpand, Hooks#event:afterRowExpand

ParamTypeDescription
rownumberVisual row index of the parent.

Returns: boolean - true if the collapsed state changed. false when the row is not a parent, when it is already expanded, or when the Hooks#beforeRowExpand hook blocked the action.

expandToLevel

Source code

nestedRows.expandToLevel(level)

Shows rows down to the given nesting level and collapses everything deeper.

Level 0 leaves only the top-level rows visible.

This runs as two steps - an expand and a collapse - so it fires both pairs of hooks. Returning false from Hooks#beforeRowExpand cancels the whole call and leaves the grid as it was. Returning false from Hooks#beforeRowCollapse blocks only the collapse step, so the expand step stays applied.

Emits: Hooks#event:beforeRowCollapse, Hooks#event:afterRowCollapse, Hooks#event:beforeRowExpand, Hooks#event:afterRowExpand

ParamTypeDescription
levelnumberThe deepest nesting level that stays expanded.

expandToRow

Source code

nestedRows.expandToRow(row) ⇒ boolean

Expands every ancestor of a row, so that a row hidden inside collapsed parents becomes visible.

Takes a physical row index, because the row you want to reveal is hidden and therefore has no visual index.

Emits: Hooks#event:beforeRowExpand, Hooks#event:afterRowExpand

ParamTypeDescription
rownumberPhysical row index of the row to reveal.

Returns: boolean - true if anything was expanded.

getCollapsedParents

Source code

nestedRows.getCollapsedParents() ⇒ Array<number>

Returns the physical row indexes of every parent row that is collapsed.

The indexes are physical, not visual, because a parent collapsed inside another collapsed parent is trimmed and therefore has no visual index at all. Physical indexes are also what you want to store when saving the state. Convert one with Core#toVisualRow.

Returns: Array<number> - Physical row indexes, sorted ascending.

getRowLevel

Source code

nestedRows.getRowLevel(row) ⇒ number | null

Returns how deeply a row is nested. Top-level rows are at level 0.

ParamTypeDescription
rownumberVisual row index.

Returns: number | null - The nesting level, or null when the row does not exist.

getRowParent

Source code

nestedRows.getRowParent(row) ⇒ number | null

Returns the parent of a row.

A visible row always has visible ancestors, so the returned index is visual like the argument.

ParamTypeDescription
rownumberVisual row index.

Returns: number | null - Visual row index of the parent, or null for a top-level row.

isEnabled

Source code

nestedRows.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 NestedRows#enablePlugin method is called.

isParent

Source code

nestedRows.isParent(row) ⇒ boolean

Checks whether a row has children.

ParamTypeDescription
rownumberVisual row index.

isParentCollapsed

Source code

nestedRows.isParentCollapsed(row) ⇒ boolean

Checks whether a parent row is collapsed.

ParamTypeDescription
rownumberVisual row index of the parent.

Returns: boolean - true if the row is a parent and its children are hidden.

toggleParent

Source code

nestedRows.toggleParent(row) ⇒ boolean

Collapses an expanded parent row, or expands a collapsed one. This is the same action as clicking the button in the row header or pressing Enter on it.

Emits: Hooks#event:beforeRowCollapse, Hooks#event:afterRowCollapse, Hooks#event:beforeRowExpand, Hooks#event:afterRowExpand

ParamTypeDescription
rownumberVisual row index of the parent.

Returns: boolean - true if the collapsed state changed.

updatePlugin

Source code

nestedRows.updatePlugin()

Updates the plugin’s state.

This method is executed when updateSettings() is invoked with any of the following configuration options: