4
votes

I have an Ext 3.4 grid with stateful:true, a stateId, and each column in the column model has an id.

Yet when I resize columns I don't see any state cookie saved, and the column widths are not restored when the page is reloaded. I do have a state Manager with cookie provider defined and I can set/get cookie values via the state manager just fine.

I also added handlers for beforestatesave and statesave and they are being called, but still - no cookie is saved and no state restored. Those handlers are being passed the correct arguments as well - the columns argument show correct updated widths when dumped into the console.

My question is: am I doing something wrong? Should I not expect this to be automatic? Do I actually have to use those state events to manually save and restore state?

2

2 Answers

4
votes

I ran into this problem myself and I figured it out only after about 2 hours of hair pulling.

Do you happen to have a rather large grid? If the cookie data exceeds 4k, which it will easily do if you have 20+ columns of data, it will not save. It will not error either.

I suppose the only other option here would be to go to a different state provider. I'm going to look at the httpProvider that Saki has graciously provided as an alternative.

EDIT:

I've tried to override the provider and remove the string escaping when saving the cookie. This reduces the size by about 50%. I cannot seem to consume it when trying to restore though. I'm certain that the Ext authors were doing this for a reason, otherwise it wouldn't make sense because it inflates the cookie by so much. So much for a hack.

1
votes

To make a GridPanel stateful I just added stateful: true to the config and setup my provider right before I create any objects

Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
   expires: new Date(new Date().getTime()+(1000*60*60*24*30)) // 30 days
}));

I've not tested if it remembers width but try moving columns and the sort order and see if they are being remembered.