ExtJS 3.4: The grid does not save or restore state automatically. What am I doing wrong?

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

However, when I resize the columns, I do not see any cookies saved, and the width of the columns is not restored when the page reloads. I have a state manager with a cookie provider installed, and I can set / get cookie values โ€‹โ€‹through the state manager just fine.

I also added handlers for beforestatesave and statesave, and they are called, but still - the cookie is not saved and the state is not restored. These handlers also pass the correct arguments โ€” the column argument shows the correct updated width when flushing to the console.

My question is: am I doing something wrong? Should I expect this to be automatic? Do I really need to use these status events to manually save and restore state?

+4
source share
2 answers

I ran into this problem myself, and I realized this only after about 2 hours of hair extension.

Do you have a pretty big grid? If the cookie data exceeds 4k, which will be easy to do, if you have 20+ columns of data, it will not be saved. This also will not be a mistake.

I believe that the only other option here would be to switch to another government provider. I will look at httpProvider that Saki has kindly provided as an alternative.

EDIT:

I tried to override the provider and delete the escape line while saving the cookie. This reduces the size by about 50%. Looks like I can't use it, trying to recover. I am sure that the authors of Ext did this for some reason, otherwise it would not make sense, because the cookie was so inflated. So much to crack.

+4
source

To make the state of GridPanel stateful, I just added stateful: true to configure and configure my provider right before creating any objects

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

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

+1
source

All Articles