Author Topic: Save state of the grid  (Read 2054 times)

j.jose

  • Newbie
  • *
  • Posts: 8
    • View Profile
Save state of the grid
« on: August 30, 2021, 07:00:59 pm »
Hello Support Team,

Is there a functionality where the state of the grid is saved and can be reloaded later.

For instance, our use case is as follows:
User A has made some columns hidden in his grid by clicking on the 'menuIcon' and modified the order of the columns by drag-and-drop function.
When he opens the grid later, is it possible to reload the last grid state again ( for example: by loading the state as a JSON file in the cookies )?

Please advise if this function already exists and if there is an example to refer to.

If not, is there a possibility to have it in the future releases?

Thanking you in advance!

Best regards,
Jiny

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Save state of the grid
« Reply #1 on: August 30, 2021, 09:39:28 pm »
This functionality already exists. Please refer this example: https://paramquery.com/pro/demos/grid_state

j.jose

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Save state of the grid
« Reply #2 on: September 01, 2021, 05:15:36 pm »
Hallo,

Thank you for the reply.
Could you please advise how the state can be saved without the buttons?
That is every time an event is triggered, the state of the grid should be saved.

Please inform me how this can be implemented.

Thanking you in advance!

Best regards,

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Save state of the grid
« Reply #3 on: September 06, 2021, 06:56:41 pm »
It's already mentioned in the demo:

Code: [Select]
        $(window).on('unload', function () {
            grid.saveState();
        });
        grid.on("destroy", function () {
            this.saveState();
        })