NestedRows
Options
nestedRows
nestedRows.nestedRows : boolean
The nestedRows option configures the NestedRows plugin.
You can set the nestedRows option to one of the following:
| Setting | Description |
|---|---|
false (default) | Disable the NestedRows plugin |
true | Enable 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` pluginnestedRows: true,Members
PLUGIN_KEY
NestedRows.PLUGIN_KEY
Returns the plugin key used to identify and access this plugin within Handsontable.
PLUGIN_PRIORITY
NestedRows.PLUGIN_PRIORITY
Returns the priority value that determines the plugin’s initialization order relative to other plugins.
Methods
collapseAll
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
nestedRows.collapseParent(row) ⇒ boolean
Collapses a parent row, which hides its children.
Emits: Hooks#event:beforeRowCollapse, Hooks#event:afterRowCollapse
| Param | Type | Description |
|---|---|---|
| row | number | Visual 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
nestedRows.countChildren(row, [recursive]) ⇒ number
Counts the children of a row.
| Param | Type | Default | Description |
|---|---|---|---|
| row | number | Visual row index. | |
| [recursive] | boolean | false | optional true counts every descendant, false counts only the direct children. |
destroy
nestedRows.destroy()
Destroys the plugin instance.
disablePlugin
nestedRows.disablePlugin()
Disables the plugin functionality for this Handsontable instance.
enablePlugin
nestedRows.enablePlugin()
Enables the plugin functionality for this Handsontable instance.
expandAll
nestedRows.expandAll()
Expands every collapsed parent row at every nesting level, so no row stays hidden.
Emits: Hooks#event:beforeRowExpand, Hooks#event:afterRowExpand
expandParent
nestedRows.expandParent(row) ⇒ boolean
Expands a parent row, which shows its children again.
Emits: Hooks#event:beforeRowExpand, Hooks#event:afterRowExpand
| Param | Type | Description |
|---|---|---|
| row | number | Visual 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
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
| Param | Type | Description |
|---|---|---|
| level | number | The deepest nesting level that stays expanded. |
expandToRow
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
| Param | Type | Description |
|---|---|---|
| row | number | Physical row index of the row to reveal. |
Returns: boolean - true if anything was expanded.
getCollapsedParents
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
nestedRows.getRowLevel(row) ⇒ number | null
Returns how deeply a row is nested. Top-level rows are at level 0.
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index. |
Returns: number | null - The nesting level, or null when the row does not exist.
getRowParent
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.
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index. |
Returns: number | null - Visual row index of the parent, or null for a top-level row.
isEnabled
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
nestedRows.isParent(row) ⇒ boolean
Checks whether a row has children.
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index. |
isParentCollapsed
nestedRows.isParentCollapsed(row) ⇒ boolean
Checks whether a parent row is collapsed.
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index of the parent. |
Returns: boolean - true if the row is a parent and its children are hidden.
toggleParent
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
| Param | Type | Description |
|---|---|---|
| row | number | Visual row index of the parent. |
Returns: boolean - true if the collapsed state changed.
updatePlugin
nestedRows.updatePlugin()
Updates the plugin’s state.
This method is executed when updateSettings() is invoked with any of the following configuration options: