Skip to content
Advertisement

REACT TABLE- Hide rows in table & reset button to display hidden rows

In my column Show there is a switch button (Toggle doesn’t seems working in sandbox, maybe because of tailwindcss? but it works in local…) when you click on it, it will turn the selected row into gray (as if the row is disabled but you can still view the content). We may have also the possibility to switch again and the original row (without gray) appears.

The VisibilityIcon button above the table will remove from all the table the gray/disabled rows (not working either). And a VisibilityoffIcon button that resets all (we get the original table).

Here what I have done but when I click on the Toggle I get errors and all the table is hidden:

JavaScript

Advertisement

Answer

  1. Keep a map of item ids that are selected and toggle these values via the Toggle component.
  2. Use separate state for the toggle button to filter the selected items.
  3. Implement a row props getter.

Example:

MenuDisplay

JavaScript

Table

JavaScript

Edit react-table-hide-rows-in-table-reset-button-to-display-hidden-rows

enter image description here enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement