This page covers a next version of Handsontable, and is not published yet.

This page covers a non-latest version of Handsontable.

# TrimRows

# Description

The plugin allows to trim certain rows. The trimming is achieved by applying the transformation algorithm to the data transformation. In this case, when the row is trimmed it is not accessible using getData* methods thus the trimmed data is not visible to other plugins.

Example

const container = document.getElementById('example');
const hot = new Handsontable(container, {
  data: getData(),
  // hide selected rows on table initialization
  trimRows: [1, 2, 5]
});

// access the trimRows plugin instance
const trimRowsPlugin = hot.getPlugin('trimRows');

// hide single row
trimRowsPlugin.trimRow(1);

// hide multiple rows
trimRowsPlugin.trimRow(1, 2, 9);

// or as an array
trimRowsPlugin.trimRows([1, 2, 9]);

// show single row
trimRowsPlugin.untrimRow(1);

// show multiple rows
trimRowsPlugin.untrimRow(1, 2, 9);

// or as an array
trimRowsPlugin.untrimRows([1, 2, 9]);

// rerender table to see the changes
hot.render();

# Options

# trimRows

Source code (opens new window)

trimRows.trimRows : boolean | Array<number>

Plugin allowing hiding of certain rows.

Default: undefined Example

// enable plugin
trimRows: true,

// or
// trim selected rows on table initialization
trimRows: [5, 10, 15],

# Methods

# destroy

Source code (opens new window)

trimRows.destroy()

Destroys the plugin instance.

# disablePlugin

Source code (opens new window)

trimRows.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

# enablePlugin

Source code (opens new window)

trimRows.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

# getTrimmedRows

Source code (opens new window)

trimRows.getTrimmedRows() ⇒ Array

Get list of trimmed rows.

Returns: Array - Physical rows.

# isEnabled

Source code (opens new window)

trimRows.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 AutoRowSize#enablePlugin method is called.

# isTrimmed

Source code (opens new window)

trimRows.isTrimmed(physicalRow) ⇒ boolean

Checks if given row is hidden.

Param Type Description
physicalRow number Physical row index.

# isValidConfig

Source code (opens new window)

trimRows.isValidConfig(trimmedRows) ⇒ boolean

Get if trim config is valid. Check whether all of the provided row indexes are within source data.

Param Type Description
trimmedRows Array List of physical row indexes.

# trimRow

Source code (opens new window)

trimRows.trimRow(...row)

Trims the row provided as physical row index (counting from 0).

Param Type Description
...row number Physical row index.

# trimRows

Source code (opens new window)

trimRows.trimRows(rows)

Trims the rows provided in the array.

Emits: Hooks#event:beforeTrimRow, Hooks#event:afterTrimRow

Param Type Description
rows Array<number> Array of physical row indexes.

# untrimAll

Source code (opens new window)

trimRows.untrimAll()

Untrims all trimmed rows.

# untrimRow

Source code (opens new window)

trimRows.untrimRow(...row)

Untrims the row provided as row index (counting from 0).

Param Type Description
...row number Physical row index.

# untrimRows

Source code (opens new window)

trimRows.untrimRows(rows)

Untrims the rows provided in the array.

Emits: Hooks#event:beforeUntrimRow, Hooks#event:afterUntrimRow

Param Type Description
rows Array<number> Array of physical row indexes.

# updatePlugin

Source code (opens new window)

trimRows.updatePlugin()

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

Last Updated: Mar 27, 2024