This is a documentation of an earlier version of Handsontable.

# CollapsibleColumns

# Description

The CollapsibleColumns plugin allows collapsing of columns, covered by a header with the colspan property defined.

Clicking the "collapse/expand" button collapses (or expands) all "child" headers except the first one.

Setting the Options#collapsiblecolumns property to true will display a "collapse/expand" button in every header with a defined colspan property.

To limit this functionality to a smaller group of headers, define the collapsibleColumns property as an array of objects, as in the example below.

Example

const container = document.getElementById('example');
const hot = new Handsontable(container, {
  data: generateDataObj(),
  colHeaders: true,
  rowHeaders: true,
  nestedHeaders: true,
  // enable plugin
  collapsibleColumns: true,
});

// or
const hot = new Handsontable(container, {
  data: generateDataObj(),
  colHeaders: true,
  rowHeaders: true,
  nestedHeaders: true,
  // enable and configure which columns can be collapsed
  collapsibleColumns: [
    {row: -4, col: 1, collapsible: true},
    {row: -3, col: 5, collapsible: true}
  ],
});

# Options

# collapsibleColumns

Source code (opens new window)

collapsibleColumns.collapsibleColumns : boolean | Array<object>

The CollapsibleColumns plugin allows collapsing of columns, covered by a header with the colspan property defined.

Clicking the "collapse/expand" button collapses (or expands) all "child" headers except the first one.

Setting the collapsibleColumns property to true will display a "collapse/expand" button in every header with a defined colspan` property.

To limit this functionality to a smaller group of headers, define the collapsibleColumns property as an array of objects, as in the example below.

Default: undefined
Example

// enable collapsing for all headers
collapsibleColumns: true,

// or
// enable collapsing for selected headers
collapsibleColumns: [
  {row: -4, col: 1, collapsible: true},
  {row: -3, col: 5, collapsible: true}
],

# Members

# headerStateManager

Source code (opens new window)

collapsibleColumns.headerStateManager : StateManager

The NestedHeaders plugin StateManager instance.

# Methods

# collapseAll

Source code (opens new window)

collapsibleColumns.collapseAll()

Collapses all collapsible sections.

# collapseSection

Source code (opens new window)

collapsibleColumns.collapseSection(coords)

Collapses section at the provided coords.

Param Type Description
coords object Contains coordinates information. (coords.row, coords.col).

# destroy

Source code (opens new window)

collapsibleColumns.destroy()

Destroys the plugin instance.

# disablePlugin

Source code (opens new window)

collapsibleColumns.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

# enablePlugin

Source code (opens new window)

collapsibleColumns.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

# expandAll

Source code (opens new window)

collapsibleColumns.expandAll()

Expands all collapsible sections.

# expandSection

Source code (opens new window)

collapsibleColumns.expandSection(coords)

Expands section at the provided coords.

Param Type Description
coords object Contains coordinates information. (coords.row, coords.col).

# isEnabled

Source code (opens new window)

collapsibleColumns.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 than the CollapsibleColumns#enablePlugin method is called.

# toggleAllCollapsibleSections

Source code (opens new window)

collapsibleColumns.toggleAllCollapsibleSections(action)

Collapses or expand all collapsible sections, depending on the action parameter.

Param Type Description
action string 'collapse' or 'expand'.

# toggleCollapsibleSection

Source code (opens new window)

collapsibleColumns.toggleCollapsibleSection(coords, [action])

Collapses/Expands a section.

Emits: Hooks#event:beforeColumnCollapse, Hooks#event:beforeColumnExpand, Hooks#event:afterColumnCollapse, Hooks#event:afterColumnExpand

Param Type Description
coords Array Array of coords - section coordinates.
[action] string optional Action definition ('collapse' or 'expand').

# updatePlugin

Source code (opens new window)

collapsibleColumns.updatePlugin()

Updates the plugin state. This method is executed when Core#updateSettings is invoked.

Last Updated: Dec 2, 2021