PDA

View Full Version : Stateful in Pagination and Fiter in Grid



jayapal
7 Jul 2011, 2:46 AM
Hi all,

I am newbie to ExtJS, previously i were using Dojo. recently I have used Grid with Pagination and Filter in Grid. Right now i used cookieprovider and stateful in my grid. It works fine in grid sorting and dragging the column. But Stateful is not working for Pagination and Filter.

All my codes are class based, so here i am sharing the required section codes.


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

Ext.extend(Ext.grid.GridPanel, {
pageSize: 30,
dataLoaded: false,
stateful: true,
stateId: 'my_state_id_grid',
--------------------------
--------------------------
}
filter.GridFilters({
local: false,
stateful: true,
stateId: 'my_state_id_grid',
--------------------------
});

Ext.PagingToolbar({
pageSize: this.pageSize,
store: this.store,
displayInfo: true,
----------------
});

I am using 3.2.1 version
Looking forward to enable stateful :),

Thanks in advance.

skirtle
7 Jul 2011, 4:25 PM
I don't think there's built in support for this but it should be possible. Take a look at the docs for the stateful option. If you also have a look at the source code for GridPanel you'll see the current getState() and applyState() methods. It shouldn't be too hard to override them in a subclass to add whatever other options you like, just make sure you remember to call the superclass implementation in your subclass.

jayapal
7 Jul 2011, 10:26 PM
I saw a thred http://www.sencha.com/forum/archive/index.php/t-62056.html in which Rugged's solution is working..





ds.on //store on
({
load:function(e)
{
//save to cookies
var state = Ext.state.Manager.getProvider();
state.set('startStore',grid.store.lastOptions.params.start);
}
});

grid.render();

//read back from cookies
var state = Ext.state.Manager.getProvider();
var start = state.get('startStore',0);

ds.load({params:{start: start, limit: 15}});




But i dono how to implement in my code. could you plz help me?

Thanks

skirtle
10 Jul 2011, 2:39 PM
I don't really know what kind of help you're expecting. I can explain what that code does if that helps.

ds is the store. On the load event, which occurs each time new data is loaded, it saves the start parameter. The other section occurs just before the store is loaded for the first time, retrieving the saved value of the start parameter before loading the store.

Though I have no doubt this would work I still stand by my original suggestion for the 'proper' way to do it.