1
Help for ParamQuery Pro / Re: Default state
« Last 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:
Load this default state on page load
On page load, retrieve the saved state string and pass it to loadState:
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 });
}