Get or set local storage value in React Grid component

28 Sep 20231 minute to read

If the enablePersistence property is set to true, the grid property value is saved in the window.localStorage for reference.
You can get/set the localStorage value by using the getItem/setItem method in the window.localStorage.

    /** get the Grid model
     * "gridGrid" is component name + component id
     */
    const value: string = window.localStorage.getItem('gridGrid');
    const model: object = JSON.parse(value);
  /** set the Grid model
   * "gridGrid" is component name + component id
   */
  window.localStorage.setItem('gridGrid', JSON.stringify(model));