PDA

View Full Version : Cant make the state provider to work



pinidbest
14 Oct 2012, 1:40 AM
Can any one supply a working sample for using a cookieprovider and saveing it an array?
I cant seem to find any working sample in the forum or anywhere.

Thanks

mitchellsimoens
15 Oct 2012, 1:43 PM
The array grid example uses the provider to save the state of the columns and such.

pinidbest
15 Oct 2012, 7:28 PM
I asked for a sample that I can use the state events like savestate and getState to state my own array with nothing to do with a grid and its properties.
There is no working sample in this forum or in the Internet.
Can you supply one.

This is a question being repeatedly being asked and with no responce.

Thanks.

mitchellsimoens
16 Oct 2012, 4:23 AM
The grid (which any component can) saves it's state so you can look at some source on how the state is being saved.

pinidbest
16 Oct 2012, 4:27 AM
Can you please supply a working sample
???

burnnat
16 Oct 2012, 9:07 AM
As simple as it gets:

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

// save data
var original = [1, 2, 3, 'a', 'b', 'c'];
Ext.state.Manager.set('data', original);

// load data
var duplicate = Ext.state.Manager.get('data');
console.log(duplicate);

For anything more complex, check out the Stateful (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.state.Stateful) mixin and the source for other stateful components like grids (as Mitchell has suggested).

pinidbest
16 Oct 2012, 9:19 PM
I will try it

pinidbest
17 Oct 2012, 3:24 AM
I didnt use Ext.JSON.encode to encode my mixed collection.

Thanks