ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: omerix on December 25, 2018, 08:38:40 pm
-
Hello,
How do I save the filter model to "saveState"?
I have to open it again when the page opens.
-
Filter values and conditions are saved in columns. It's enabled by default and configurable through stateColKeys option.
https://paramquery.com/pro/api#option-stateColKeys
https://paramquery.com/pro/demos/grid_state
-
I beg your pardon. I tried it right now, but it didn't. Can you give sample code? What can I do?
,stateColKeys:{filterModel:1}
-
I've added this code.
,stateKeys : {filterModel:['header','on','mode','type','timeout']}
In "Storage", I see "header true".
But "header" is not open.
-
There is inbuilt support to restore only existing default models ( groupModel, pageModel & sortModel in stateKeys ) via loadState.
filterModel can be added in localStorage via stateKeys but loadState can't restore it automatically.
you might need to read filterModel from localStorage directly and update filterModel of grid.
-
...you might need to read filterModel from localStorage directly and update filterModel of grid.
I don't know how to do that. I will try to make it.
-
Please use this
create: function () {
//restore state of grid.
this.loadState({
refresh: false
});
var state = JSON.parse(localStorage.getItem("pq-grid"+this.element[0].id ));
this.option('filterModel.header', state.filterModel.header);
},
-
Thanks Param.
Works very well
this.loadState({refresh: false});
var state = JSON.parse(localStorage.getItem("pq-grid"+this.element[0].id));
if (state!=null) {
console.log(this.element[0].id);
this.option('filterModel', state.filterModel);
this.option('menuIcon', state.menuIcon);
};