PDA

View Full Version : Ext.data.Store reload problem



sharp20
19 Oct 2007, 10:34 AM
Hello,

I use a Ext.data.Store and a Ext.grid.EditorGrid in order to make a paginated list of records. I would like that when I am on some page, different from the first page, and I click a button on the grid toolbar, to reload the exact page am on, with some eventual changes. I read on the forums that I could use:


ds.reload();

If I use it like that it gives back the results from the page I was on at that moment, but I would also like to specify some other parameters inside that reload. I tried this


ds.reload({params:{option:op, id:id, ec:ec}});

but now it doesn't "remember" the start parameter, which I used in order to get the page I wanted. And in the paging toolbar I have "Page NaN of 14" .

Can some one please help me a little bit ?

Thank you.

Animal
20 Oct 2007, 1:42 AM
Your params are overwriting the params from the last options use.

Store stores the options object passed to load, and uses all those options in reload unless overriden. You are overriding the params property.

try



ds.reload({params: Ext.apply({option:op, id:id, ec:ec}, ds.lastOptions.params)});

[/code]

sharp20
21 Oct 2007, 12:20 AM
Thank you very much Animal. It worked perfectly ! :)

Animal
21 Oct 2007, 12:24 AM
Mmmm, but do you understand why?

Have I given you a fish, or taught you how to fish?

sharp20
21 Oct 2007, 8:13 AM
I understand what overriding the params property means. I initially thought that if I use reload (instead of load), the old params would also have been taken into account. But I now see that I had to add ds.lastOptions.params.

There's another problem i'm facing with right now. I'm trying to get just some (one or two) parameters that were previously used. ds.lastOptions.params returns all the params. Is there a way to consider only a param called start ?

Or do you think it should be wise to use cookies instead, for the this thing I need ?

Animal
21 Oct 2007, 9:00 AM
Use ds.lastOptions. Pick out the params you need.