ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: queensgambit9 on August 27, 2025, 05:55:03 pm

Title: Default state
Post by: queensgambit9 on August 27, 2025, 05:55:03 pm
Would it be possible to have a button in the toolbar to set a selected state as "default" (to be loaded on page load)?
Title: Re: Default state
Post by: paramvir on August 27, 2025, 08:42:36 pm
Yes, it’s possible to implement a “Set as Default” button in the toolbar using the saveState and loadState APIs. Here’s the approach:

Save the selected state as a string
When the user clicks your “Set as Default” button, call saveState and save the returned string somewhere persistent—like local storage or your database. For example:

Code: [Select]
const defaultState = grid.saveState({ stringify: true });
localStorage.setItem('myGridDefaultState', defaultState);

Load this default state on page load
On page load, retrieve the saved state string and pass it to loadState:

Code: [Select]
const savedState = localStorage.getItem('myGridDefaultState');
if (savedState) {
    grid.loadState({ state: savedState, refresh: true });
}