I want to restore a state of a Listgrid with setViewState. But when I use this method with the string obtained earlier with getViewState as a parameter, only he sorting of column appear, the order of the column is not the same and the hidden column are shown.
A standalone test case is one that can be immediately run with no external dependencies. What you’ve posted is not useful as we already have automated tests verifying that this feature works. The most likely explanation bug in your code, but if it were possible to prepare a standalone, minimal test case there would be a reason to look into the problem as a possible bug.
Appears to be invalid. The string ends up being evaluated as javascript on the client but the escaping for various quotation marks is incorrect which would cause errors - when you run this code I’d expect to see an error in the developer console window saying something like “Unable to parse viewState”.
How did you initially get this string - presumably it was returned from a call to getViewState() at some point but was it directly copied / pasted from somewhere? Did you hand edit it at all?
I have seen so many post saying it’s a wrong quoted string without showing a example of the valid quoted string. Isomorphic, could you please post a example of valid quoted string from ListGrid.getViewState(), which could be passed to the server and received from the server (using JSON) and successfully restore the ListGrid state.
Thanks
problem solved thanks!
If anybody interested, this is how I pass the state to the server
String pref = grid.getViewState();
pref = JsonUtils.escapeValue(pref);
I also remove first and last " from the string.