PDA

View Full Version : How do you load all of the data from a store with paging instead of just the cache



beckdawg
16 Apr 2012, 8:31 AM
As I understand things, a grid with paging will load that page into it's cache. I've been asked to implement a print functionality. Given that there is a plugin that does a lot of this I've just started altering it for my needs. It doesn't print the entire data set instead just the current page. I would argue that is correct behavior but I don't apparently get an opinion here at work.

So, I need to know how to load all the data in a store that has paging. I tried something like


grid.store.getRange(0, grid.store.getTotalCount( ));

That just returned what was in the current cache rather than the entire dataset.

As I understand our code, they are already grabbing the entire data set when the initially call the back end and storing it in memory. So, in theory this shouldn't kill performance. But, I need to know how to grab all of it for the case of printing.

dedoz
16 Apr 2012, 9:00 AM
1) maybe you can try setting the pageSize config = totalCount and then perform a load ? this should load all the records like one page. this can affect grid and whats users is watching tho.

2) make another store instance and do 1)

3) make server side know that u want to load all the records and it should ignore page / start / limit params like
store.load({params:{type:"load_all"}});

theres many ways to do what you wanna do :d
hope this helps

beckdawg
16 Apr 2012, 11:10 AM
I think what you suggested should work. Something like say


var newStore = grid.store;
newStore.pageSize = grid.store.getTotalCount();
newStore.load();


Only thing I'm not sure of is I can't remember if that assigns a pointer to newStore or if it's a legit copy of the memory. If it's a pointer, it's going to screw up the grid on the other page by increasing the pageSize. I'm having trouble testing this on the existing code since what I am testing it on doesn't actually use paging for some reason.

Either way, I think this answers my initial question. Thanks.

dedoz
16 Apr 2012, 12:47 PM
if u dont want a pointer, then just create another instance
var newstore = Ext.create('same store type');

you can use Ext.getClass or similar to get grid.store class, i think store has a property that will tell you its type