How can I help you?
State persistence in React TreeGrid
8 Oct 20251 minute to read
State persistence maintains the TreeGrid state in the browser’s localStorage across page refreshes and intra-tab navigation.
TreeGrid stores its model in local storage when enablePersistence is set to true.
Get or set local storage value
When enablePersistence is true, TreeGrid property values are saved in window.localStorage. Use getItem and setItem to retrieve or assign the stored model.
// Get the TreeGrid model.
const value: string = window.localStorage.getItem('treegridTreeGrid') as string; //"treegridTreeGrid" is component name + component id.
const model: object = JSON.parse(value); // Set the TreeGrid model.
window.localStorage.setItem('treegridTreeGrid', JSON.stringify(model)); //"treegridTreeGrid" is component name + component id.Refer to the React TreeGrid feature tour page for highlights. Explore the React TreeGrid example for data presentation and manipulation options.