PDA

View Full Version : Store reload() issue



LupcoB
9 May 2007, 4:44 PM
Hi guys, im trying to use the reload method to pass additional data to a data-generating page, while also maintaining paging for a grid. for e.g.

ds.load({params:{start:0, limit:20}});
.........
.........
ds.reload({params: {delete: id}});

basically my aim is to remove an item while also refreshing the contents of the grid (to reflect this change).

The issue that im experiencing is that the paging properties dont end up getting passed into the data-generating page. Since the reload method is using ApplyIf, the 'param' properties exist in both objects, therefore not applying the paging properties to this additional parameter.

What would be the best way to go around this without actually editing Ext?

Thanks,
Lupco

jsakalos
9 May 2007, 4:53 PM
I solved the same problem by adding function reload to the paging toolbar:



paging.reload = function() {
this.ds.load({params: {start: this.cursor, limit: this.pageSize}});
}


You can add additional arguments to such a function to make it more versatile.

Don't know if my solution is best but it works for me.

LupcoB
9 May 2007, 5:36 PM
Thanks, what ive formulated is this:


paging.reload = function(params) {
var tmp_params = Ext.applyIf(params.params||{}, {start:this.cursor,limit:this.pageSize});
var tmp_options = {params: tmp_params};
this.ds.load(Ext.applyIf(tmp_options, params));
};

Animal
10 May 2007, 12:36 AM
Wouldn't setting the Store's baseParams before the standard load call work?

LupcoB
10 May 2007, 1:35 AM
Probably, but then i've gotta reset the baseParams back to normal since i only want this data passed once.