PDA

View Full Version : Infinite Grid on store load



nkezhaya
18 Jan 2012, 3:00 PM
I'm using guaranteeRange() on the store for my infinite grid, which makes the load callback for the Store behave very strangely (namely, the first parameter passed to the callback function is just an empty object).

How can I execute the callback in the controller, cleanly?

I'm passing back a "total" option from my server and I want to update a count on the grid to show how many total records there are in the database.

mitchellsimoens
19 Jan 2012, 9:39 AM
You should use the prefetch event on the store:


listeners : {
prefetch : function(store) {
console.log(store.getTotalCount());
}
}

Or in the callback of store.prefetch:


store.prefetch({
start: 0,
limit: 99,
callback: function() {
console.log(this.getTotalCount());
store.guaranteeRange(0, 49);
}
});

nkezhaya
19 Jan 2012, 9:56 AM
Gah!

Why is there no prefetch event in the Store documentation? All I see is beforeprefetch!

This would have saved a thread here.

Thank you.

mitchellsimoens
19 Jan 2012, 10:37 AM
Not sure... there should be... I actually just guessed :)

nkezhaya
19 Jan 2012, 10:38 AM
Oh, hehe...

I haven't verified the solution because I found an alternative that works, but I was curious to know what the solution would have been. Future reference, and all that... :)

Wouldn't be surprised, though. There's a lot of hidden stuff that works that isn't documented.

mitchellsimoens
19 Jan 2012, 10:39 AM
Yeah... documentation is an ongoing venture, there will never be an end.

nkezhaya
19 Jan 2012, 10:41 AM
Are you guys hiring? ;)

mitchellsimoens
19 Jan 2012, 10:47 AM
Always... send me an email mitchell.simoens [at] sencha.com Would like to see some examples too!