Persisting filters when using Insert, Update, or Delete rows with Form
The default behavior of a Table component is to reset the filters when the underlying data is refreshed. In order to persist existing filters when updating and refreshing table data, please follow this guide.
Create a Temporary state variable to store the filters
- Click into the “State” Pane on the left sidebar
- Create a new Temporary state variable
- Rename it
tableFilters
- Set the Default Value to be
{}
to match the default table filters of the Table component - In the Table component's event handlers, add
onFiltersChanged
and set the state variable to be the Table's filter object{{Table1.filters}}
This will now track all the changes to the filters of the Table component and save them into the state variable that can be accessed later.
Update the Table’s filters when changes are made
info
Pre-requisites: Follow our Table bulk edit and update tutorial to learn how to set up the APIs for steps 1.1 and 1.2.
- In the Table component's event handlers, update
onSaveChanges
to:- Run the API to update the underlying dataset, in this example
bulkEditAPI
- Run the API to refresh the Table’s dataset, in this example
getTableDataAPI
- Set the Table’s Filters to the value of the state variable with
{{tableFilters.value}}
- Run the API to update the underlying dataset, in this example
- Now, when the Table’s data is edited in-line, the filters will automatically get reapplied after the data is refreshed