ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: mikep on September 15, 2020, 06:16:52 pm
-
Saving/Loading from from browser storage works great, but when I send in the state using state parameter, it's ignoring this and just loading the browser stored state. Any suggestions?
var temp = "{'colModel':[{'dataIndx':'res','width':20}.......}";
$gridMain.pqGrid("loadState",temp);
-
Please check the syntax of method call:
$gridMain.pqGrid("loadState", { state: temp });
-
I'm getting an error with using my state parameter. I'm guessing it's not formatted correctly.
I got the json string using saveState, and replaced the double quotes w/singe quotes and use that as my param. Any ideas why this doesn't work?
"{'colModel':[{'dataIndx':'res','width':283},{'dataIndx':'proj','width':275},{'dataIndx':'id','width':240,'hidden':true},{'dataIndx':'projectuid','width':240,'hidden':true},{'dataIndx':'resourceuid','width':240,'hidden':true},{'dataIndx':'Notes','width':200,'filter':{},'hidden':true},{'dataIndx':'JO Base Alloc','width':200,'filter':{},'hidden':true},{'dataIndx':'JO Remaining Alloc','width':200,'hidden':true},{'dataIndx':'RBS','width':200,'hidden':true},{'dataIndx':'CCDivF','width':200,'hidden':true},{'dataIndx':'CCDivH','width':200,'hidden':true},{'dataIndx':'CostCenter_','width':200,'hidden':true},{'dataIndx':'EmployeeNumber','width':200,'hidden':true},{'dataIndx':'JO','width':59},{'dataIndx':'JOSO','width':69},{'dataIndx':'JOGROUP','width':200,'hidden':true},{'dataIndx':'JODivision','width':200,'hidden':true},{'dataIndx':'01/01/20~b8f70726-2c22-4c69-b48c-da7ae88d6837','width':70},{'dataIndx':'Range Total','width':70}],'datestamp':1600345733432,'height':600,'width':'100%','freezeRows':0,'freezeCols':4,'groupModel':{'dataIndx':[],'collapsed':[false]},'pageModel':{'curPage':1,'rPP':10},'sortModel':{'sorter':[{'dataIndx':'res','dir':'down'}]}}"
-
Does it work without replacement of the double quotes w/singe quotes?
Could you please share a jsfiddle.
-
Yes, it actually does. Thank you!
-
I'm using multiple grouping levels in my grid. Is there a way to save the expand/collapse state of a row in the savestate method? If not is there a strategy I could implement to achieve this?
-
Please read about nodeClose property of groupModel. https://paramquery.com/pro/api#option-groupModel
and add it in stateKeys property:
stateKeys: { groupModel: ['dataIndx', 'collapsed', 'grandSummary', 'nodeClose'] },
Example of usage:
https://paramquery.com/pro/demos/grid_state
-
Thank you. That works. However, there's a scenario where I'm selecting a new grid state from a dropdown list without reloading the page and it's not working. Any ideas why?
var obj = document.getElementById("selViews");
var gState = obj.options[obj.selectedIndex].getAttribute('rpmGridState')
const search = '\\"';
const replaceWith = '"';
const result = gState.split(search).join(replaceWith);
success = $gridMain.pqGrid("loadState", { state: result });
$gridMain.pqGrid('option', 'title', "Current View: " + obj.options[obj.selectedIndex].text);
$gridMain.pqGrid("refreshView");
-
Please remove the last line and recheck:
$gridMain.pqGrid("refreshView");
-
Works! Thanks. If I have a column filter applied to one viewstate and change to another viewstate (w/no filter), the filter remains. Any ideas on how to remove this for the viewstate which doesn't have a filter applied?
-
Please clear the previous filtering in grid before load another state:
grid.reset({filter: true});
-
Thanks, that works great.
If I try to load state using this: result = $gridMain.pqGrid("loadState", { state: result });
and a recently added field in the grid doesn't exist in the state, I get this error: Uncaught TypeError: Cannot read property 'dataIndx' of undefined
What's the best way to either avoid this error or get the "result" var back, in order to let the user know that the state is old and doesn't contain 1 or more grid fields.
-
That shouldn't be a problem ( error ), which version of grid are you using? Could you please share a jsfiddle as well.