docs/content/guides/rows/row-hiding/row-hiding.md
Hide individual rows to avoid rendering them as DOM elements. It helps you reduce screen clutter and improve the grid's performance.
[[toc]]
"Hiding a row" means that the hidden row doesn't get rendered as a DOM element.
When you're hiding a row:
HiddenRows plugin doesn't participate in data transformation
(the shape of the data returned by the getData*() methods stays intact).To enable row hiding, use the hiddenRows option.
::: only-for javascript
::: example #example1 --js 1 --ts 2
:::
:::
::: only-for react
::: example #example1 :react --js 1 --ts 2
:::
:::
::: only-for angular
::: example #example1 :angular --ts 1 --html 2
:::
:::
::: only-for vue
::: example #example1 :vue3
@code
:::
:::
To set up your row hiding configuration, follow the steps below.
To both enable row hiding and specify rows hidden by default, set the hiddenRows configuration option to an object.
In the object, add a rows property, and set it to an array of row indexes.
Now, those rows are hidden by default:
::: only-for javascript
::: example #example2 --js 1 --ts 2
:::
:::
::: only-for react
::: example #example2 :react --js 1 --ts 2
:::
:::
::: only-for angular
::: example #example2 :angular --ts 1 --html 2
:::
:::
::: only-for vue
::: example #example2 :vue3
@code
:::
:::
To easily see which rows are currently hidden, display UI indicators.
To enable the UI indicators, in the hiddenRows object, set the indicators property to true:
::: only-for javascript
::: example #example3 --js 1 --ts 2
:::
:::
::: only-for react
::: example #example3 :react --js 1 --ts 2
:::
:::
::: only-for angular
::: example #example3 :angular --ts 1 --html 2
:::
:::
::: only-for vue
::: example #example3 :vue3
@code
:::
:::
To easily hide and unhide rows, add row hiding items to Handsontable's context menu.
Enable both the ContextMenu plugin and the HiddenRows plugin. Now, the context menu automatically displays additional items for hiding and unhiding rows.
::: only-for javascript
::: example #example4 --js 1 --ts 2
:::
:::
::: only-for react
::: example #example4 :react --js 1 --ts 2
:::
:::
::: only-for angular
::: example #example4 :angular --ts 1 --html 2
:::
:::
::: only-for vue
::: example #example4 :vue3
@code
:::
:::
You can also add the row hiding menu items individually, by adding the hidden_rows_show and hidden_rows_hide strings to the contextMenu parameter:
::: only-for javascript
::: example #example5 --js 1 --ts 2
:::
:::
::: only-for react
::: example #example5 :react --js 1 --ts 2
:::
:::
::: only-for angular
::: example #example5 :angular --ts 1 --html 2
:::
:::
::: only-for vue
::: example #example5 :vue3
@code
:::
:::
By default, hidden rows are included in copying and pasting.
To exclude hidden rows from copying and pasting, in the hiddenRows object, set the copyPasteEnabled property to false:
::: only-for javascript
::: example #example6 --js 1 --ts 2
:::
:::
::: only-for react
::: example #example6 :react --js 1 --ts 2
:::
:::
::: only-for angular
::: example #example6 :angular --ts 1 --html 2
:::
:::
::: only-for vue
::: example #example6 :vue3
@code
:::
:::
::: only-for react
::: tip
To use the Handsontable API, you'll need access to the Handsontable instance. You can do that by utilizing a reference to the HotTable component, and reading its hotInstance property.
For more information, see the Instance methods page.
:::
:::
For the most popular row hiding tasks, use the API methods below.
To see your changes, re-render your Handsontable instance with the render() method.
::: only-for angular
To obtain the Handsontable instance from the Angular wrapper component, you can use Angular's @ViewChild decorator to reference the HotTableComponent and then access its hotInstance property.
@ViewChild(HotTableComponent, {static: false})
hotTable!: HotTableComponent;
ngAfterViewInit() {
// The Handsontable instance is available through the hotInstance property
const hot = this.hotTable.hotInstance;
// You can now use the "hot" instance to call Handsontable's API methods
// ...
}
:::
:::: only-for vue
::: tip
To use the Handsontable API, you'll need access to the Handsontable instance. You can do that by utilizing a reference to the HotTable component, and reading its hotInstance property.
For more information, see the Instance methods page.
:::
::::
HiddenRows plugin instanceTo access the HiddenRows plugin instance, use the getPlugin() method:
const plugin = hot.getPlugin('hiddenRows');
To hide a single row, use the hideRow() method:
const plugin = hot.getPlugin('hiddenRows');
plugin.hideRow(4);
To hide multiple rows:
hideRow() methodhideRows() methodconst plugin = hot.getPlugin('hiddenRows');
plugin.hideRow(0, 4, 6);
// or
plugin.hideRows([0, 4, 6]);
To unhide a single row, use the showRow() method:
const plugin = hot.getPlugin('hiddenRows');
plugin.showRow(4);
To unhide multiple rows:
showRow() methodshowRows() methodconst plugin = hot.getPlugin('hiddenRows');
plugin.showRow(0, 4, 6);
// or
plugin.showRows([0, 4, 6]);
Configuration options
<div class="boxes-list"> </div>Hooks
<div class="boxes-list"> </div>Plugins
<div class="boxes-list"> </div>