JavaScript Data GridTrimRows
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 codetrimRows.trimRows : boolean | Array<number>
The trimRows
option configures the TrimRows
plugin.
You can set the trimRows
option to one of the following:
Setting | Description |
---|---|
false | Disable the TrimRows plugin |
true | Enable the TrimRows plugin |
An array of physical row indexes | - Enable the TrimRows plugin- Trim selected rows at initialization |
Read more:
Default: undefined
Example
// enable the `TrimRows` plugin
trimRows: true,
// enable the `TrimRows` plugin
// at Handsontable's initialization, trim rows 5, 10, and 15
trimRows: [5, 10, 15],
Methods
destroy
Source codetrimRows.destroy()
Destroys the plugin instance.
disablePlugin
Source codetrimRows.disablePlugin()
Disables the plugin functionality for this Handsontable instance.
enablePlugin
Source codetrimRows.enablePlugin()
Enables the plugin functionality for this Handsontable instance.
getTrimmedRows
Source codetrimRows.getTrimmedRows() ⇒ Array
Get list of trimmed rows.
Returns: Array
- Physical rows.
isEnabled
Source codetrimRows.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 AutoRowSize#enablePlugin method is called.
isTrimmed
Source codetrimRows.isTrimmed(physicalRow) ⇒ boolean
Checks if given row is hidden.
Param | Type | Description |
---|---|---|
physicalRow | number | Physical row index. |
isValidConfig
Source codetrimRows.isValidConfig(trimmedRows) ⇒ boolean
Get if trim config is valid. Check whether all of the provided physical row indexes are within source data.
Param | Type | Description |
---|---|---|
trimmedRows | Array | List of physical row indexes. |
trimRow
Source codetrimRows.trimRow(...row)
Trims the row provided as a physical row index (counting from 0).
Param | Type | Description |
---|---|---|
...row | number | Physical row index. |
trimRows
Source codetrimRows.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 codetrimRows.untrimAll()
Untrims all trimmed rows.
untrimRow
Source codetrimRows.untrimRow(...row)
Untrims the row provided as a physical row index (counting from 0).
Param | Type | Description |
---|---|---|
...row | number | Physical row index. |
untrimRows
Source codetrimRows.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 codetrimRows.updatePlugin()
Updates the plugin's state.
This method is executed when updateSettings()
is invoked with any of the following configuration options: