TrimRows
Plugin: 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
import { AfterViewInit, Component, ViewChild } from "@angular/core";import { GridSettings, HotTableModule, HotTableComponent,} from "@handsontable/angular-wrapper";
`@Component`({ selector: "app-example", standalone: true, imports: [HotTableModule], template: ` <div> <hot-table [settings]="gridSettings" /> </div>`,})export class ExampleComponent implements AfterViewInit { `@ViewChild`(HotTableComponent, { static: false }) readonly hotTable!: HotTableComponent;
readonly gridSettings = <GridSettings>{ data: this.getData(), // Hide selected rows on table initialization trimRows: [1, 2, 5], };
ngAfterViewInit(): void { // Access the trimRows plugin instance const hot = this.hotTable.hotInstance; const trimRowsPlugin = hot.getPlugin("trimRows");
// Hide a single row trimRowsPlugin.trimRow(1);
// Hide multiple rows trimRowsPlugin.trimRow(1, 2, 9);
// Or as an array trimRowsPlugin.trimRows([1, 2, 9]);
// Show a single row trimRowsPlugin.untrimRow(1);
// Show multiple rows trimRowsPlugin.untrimRow(1, 2, 9);
// Or as an array trimRowsPlugin.untrimRows([1, 2, 9]);
// Re-render table to see the changes hot.render(); }
private getData(): any[] { // Get some data }}Options
trimRows
trimRows.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` plugintrimRows: true,
// enable the `TrimRows` plugin// at Handsontable's initialization, trim rows 5, 10, and 15trimRows: [5, 10, 15],Methods
destroy
trimRows.destroy()
Destroys the plugin instance.
disablePlugin
trimRows.disablePlugin()
Disables the plugin functionality for this Handsontable instance.
enablePlugin
trimRows.enablePlugin()
Enables the plugin functionality for this Handsontable instance.
getTrimmedRows
trimRows.getTrimmedRows() ⇒ Array
Get list of trimmed rows.
Returns: Array - Physical rows.
isEnabled
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 then the TrimRows#enablePlugin method is called.
When [[Options#dataProvider]] is a complete server-backed configuration, the DataProvider plugin blocks this plugin from enabling.
isTrimmed
trimRows.isTrimmed(physicalRow) ⇒ boolean
Checks if given row is hidden.
| Param | Type | Description |
|---|---|---|
| physicalRow | number | Physical row index. |
isValidConfig
trimRows.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
trimRows.trimRow(…row)
Trims the row provided as a physical row index (counting from 0).
| Param | Type | Description |
|---|---|---|
| …row | number | Physical row index. |
trimRows
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
trimRows.untrimAll()
Untrims all trimmed rows.
untrimRow
trimRows.untrimRow(…row)
Untrims the row provided as a physical row index (counting from 0).
| Param | Type | Description |
|---|---|---|
| …row | number | Physical row index. |
untrimRows
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
trimRows.updatePlugin()
Updates the plugin’s state.
This method is executed when updateSettings() is invoked with any of the following configuration options: