Custom AdapTable State
Summary
- Bespoke data can be stored in AdapTable State by using the Application section
AdapTable provides the Application section of Initial Adaptable State for storing custom state.
Hint
To persist custom data outside of Adaptable State (e.g. in an envelope wrapping it), do so in persistState and unwrap it again in loadState
Application contains a simple set of key / value pairs designed for storing bespoke data.
A common use case is to store grid-related options which the User changed (e.g. Filter Bar visibility).
AdapTable takes care of the full persistence / retrieval of these objects as part of Adaptable State
Custom Data in Adaptable State
- This example shows how you can use Application section of Adaptable State to store custom data, persisted between sessions via custom
loadState/persistState - Persistence uses a mock remote service here; in production call your own API from the same functions (e.g. Supabase, Firebase, S3, etc.)
- 2 properties are kept in Application State:
- the time when the button was clicked
- whether Filter bar is displayed
- When the demo first loads the Grid shows with the Filter Bar hidden (as visibility was set to false in Filter Options) and with the Button showing loaded time
- Each time Filter Bar Visibility is changed - either through Toolbar or via the Column Menu - an entry in Application State is updated
- Likewise each time the Button is clicked the Application State is updated and the Button displays the time it was updated
- Refreshing the grid will display the Grid with Filter bar as it was last set and the button showing the last time it was clicked
Try It Out
- Refresh the page and note that the Filter Bar visibility is the same value to which it was last set and the Button time is not updated
- Reset the persisted state and note that now the Filter Bar is hidden (as value from Filter Options is used) and the Button click count is reset
Loading demo…
Find Out More
Application State and the Application API are in the AdapTable State Technical Reference