Author Topic: Storing states in database  (Read 276 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 347
    • View Profile
Storing states in database
« on: May 13, 2025, 01:16:55 pm »
Hi

I am currently using states (localstorage). Is there a tutorial or example on how to instead store in database along with user data. Using MySQL/PHP.

Thanks in advance.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6394
    • View Profile
Re: Storing states in database
« Reply #1 on: May 13, 2025, 08:05:26 pm »
There is no demo for saving it in db as the process also involves user authentication to tie / associate the state with the user.

If you have user authentication already in place, then the process is quite simple:

first receive the state as string with saveState method and pass save: false to the method so as to avoid saving it to localStorage.

post the state string to remote url along with user token id and save it in a single field corresponding to the user in a table.

Get the state corresponding to the user whenever required and use loadState method to restore the state of the grid.

https://paramquery.com/pro/api#method-saveState

https://paramquery.com/pro/api#method-loadState