PDA

View Full Version : How to save/load Grid columns view state (hidden or not) in a cookie?



KTamas
26 Apr 2008, 4:30 AM
Hi

So I've discovered ExtJS not a long time ago and I'm already in love with the GridPanel because it provides exactly what I need, however, there is one thing I absolutely need: since it provides a way to hide columns, I have to store it in a cookie so when the user comes back to the page, he gets only the columns he needs.

Can anyone help me? I'm sure it's possible in ExtJS but I can't find the solution.

Thanks,
KTamas

KTamas
27 Apr 2008, 5:45 AM
Anyone?...

evant
27 Apr 2008, 5:47 AM
You can access an array of columns directly on the column model:



var cm = myGrid.getColumnModel();
Ext.each(cm.config, function(col, idx)
{
var isHidden = cm.isHidden(idx);
//etc
}
);

KTamas
27 Apr 2008, 5:58 AM
You can access an array of columns directly on the column model:



var cm = myGrid.getColumnModel();
Ext.each(cm.config, function(col, idx)
{
var isHidden = cm.isHidden(idx);
//etc
}
);

Is it possible to save the whole ColumnModel in a cookie? Or do I have to iterate through each item and save its state?

KTamas
28 Apr 2008, 12:42 AM
Nevermind, solved the problem with evant's code and jQuery's cookie plugin. Thank you again, evant!

KTamas
30 Apr 2008, 4:53 AM
...or I could just say

Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
>.<