Permalink
Browse files

Allow for readjusting preload count and node height based on last tot…

…al returned from query (can be progressively more accurate with each response).
  • Loading branch information...
1 parent 9a1ef9c commit 07e6c8e8d459aa5a2b5e2438a6cf01af1f588336 @kriszyp committed Feb 16, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 OnDemandList.js
View
@@ -274,7 +274,7 @@ return declare([List, _StoreMixin], {
preload.count -= count;
var beforeNode = preloadNode,
keepScrollTo, queryRowsOverlap = grid.queryRowsOverlap,
- below = preloadNode.rowIndex > 0;
+ below = preloadNode.rowIndex > 0 && preload;
if(below){
// add new rows below
var previous = preload.previous;
@@ -341,6 +341,17 @@ return declare([List, _StoreMixin], {
// so we don't "jump" in the scrolling position
scrollNode.scrollTop += beforeNode.offsetTop - keepScrollTo;
}
+ if(below){
+ // if it is below, we will use the total from the results to update
+ // the count in case the total changes as later pages are retrieved
+ // (not uncommon when total counts are estimated for db perf reasons)
+ Deferred.when(results.total || results.length, function(total){
+ // recalculate the count
+ below.count = total - below.node.rowIndex;
+ // readjust the height
+ adjustHeight(below);
+ });
+ }
});
preload = preload.previous;

0 comments on commit 07e6c8e

Please sign in to comment.