ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on March 06, 2016, 02:48:45 am

Title: save multiple states of grid in Localstorage
Post by: queensgambit9 on March 06, 2016, 02:48:45 am
Hi

Im using the saveState and loadState functions which works fine. Now I would like to have the possibility to save and load different states.
Example: I save current state with a user input name which then will be available in a loadstate dropdown. This mean the user can save states and then choose to load a certain state. Preferably also with the possibility to rename or delete a state.

Would that be possible and how could a solution for that look like?

Thanks.
Title: Re: Localstorage (saveState and loadState)
Post by: paramvir on March 07, 2016, 12:43:54 pm
saveState( { save: false } ) returns a string which you can name and save it in an object.

Code: [Select]
var saveStates = {
  key1: saveState1,
  key2: saveState2,
  key3: saveState3,
  ...
}

In the dropdown add the name of states as options

When the user selects key1, call loadState( { state: saveStates[ 'key1' ]  }) to load corresponding state.
Title: Re: Localstorage (saveState and loadState)
Post by: queensgambit9 on August 23, 2017, 06:17:48 pm
I save different states to local Storage with different keys.
How can I read these and populate dropdown on page load?

http://jsfiddle.net/rcw7114y/

Thanks.



Title: Re: Localstorage (saveState and loadState)
Post by: paramvir on August 24, 2017, 04:40:38 pm
Please check this:

http://jsfiddle.net/rcw7114y/1/
Title: Re: Localstorage (saveState and loadState)
Post by: queensgambit9 on August 24, 2017, 04:52:01 pm
Thanks. Would it be possible to populate the drop down with all states available from local storage on page load?
Title: Re: Localstorage (saveState and loadState)
Post by: paramvir on August 24, 2017, 04:59:01 pm
yes, please check this

http://jsfiddle.net/rcw7114y/2/
Title: Re: save multiple states of grid in Localstorage
Post by: queensgambit9 on August 25, 2017, 01:06:43 am
Having an issue...after you enter name of the state (new, does not exist) the select visible column gets "destroyed"...?

http://jsfiddle.net/rcw7114y/3/
Title: Re: save multiple states of grid in Localstorage
Post by: queensgambit9 on August 25, 2017, 02:14:38 pm
Also, been trying to add a text instead of the localStorage key name to be displayed in the dropdown...how can I add the text when pushing the item to options array?
Title: Re: save multiple states of grid in Localstorage
Post by: paramvir on August 25, 2017, 03:01:24 pm
Please check this:

http://jsfiddle.net/rcw7114y/4/
Title: Re: save multiple states of grid in Localstorage
Post by: queensgambit9 on August 25, 2017, 07:59:22 pm
Great, thanks.
If I would like to load state from qs, like: pq.html?state=statename, where should I execute the loadstate?

Have something like this:

Code: [Select]
var state = localStorage.getItem(prefix() + qsState);
          this.loadState({
            state: state
          })

No success though and can I load it by a more efficient way (The dropdown should be selected with the state from qs also)?
Title: Re: save multiple states of grid in Localstorage
Post by: queensgambit9 on August 28, 2017, 02:44:10 am
Solved.
Title: Re: save multiple states of grid in Localstorage
Post by: queensgambit9 on August 28, 2017, 06:50:43 pm
Afraid not  :)
Having problems with pqSelect filters
The information is correct in the local storage value. Seems it doesn't get refreshed when I execute the loadstate for qs load?

 
Code: [Select]
create: function() {
     
    var state = localStorage.getItem(prefix() + qsState);
           
         this.loadState({
            state: state
          })

refreshToolbar(this);
$("#loadState").val(qsState);
}
Title: Re: save multiple states of grid in Localstorage
Post by: queensgambit9 on August 29, 2017, 12:53:45 pm
To clarify, I use ?state=state as qs and want the state to be loaded...and it does but the filters with pqselect does not get updated...

http://jsfiddle.net/fwmLo4jd/1/
Title: Re: save multiple states of grid in Localstorage
Post by: paramvir on August 29, 2017, 06:48:52 pm
Let's make the filters work with localStorage first as this post is about localStorage

Please check this: http://jsfiddle.net/mo6p4uvt/
Title: Re: save multiple states of grid in Localstorage
Post by: queensgambit9 on August 29, 2017, 06:58:05 pm
Great, thanks.