Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Requery paged data if observed changes cause the data to no longer ma…

…tch the page size.
  • Loading branch information...
commit c31d76d157ac253c824c8d35e205fc3334217cd1 1 parent 40f339e
@kriszyp authored
View
6 List.js
@@ -463,6 +463,7 @@ function(arrayUtil, kernel, declare, listen, has, miscUtil, TouchScroll, hasClas
options.count++;
}
from != to && firstRow && self.adjustRowIndices(firstRow);
+ self._onRowsNotification(rows)
}, true)) - 1;
}
var rowsFragment = document.createDocumentFragment();
@@ -495,7 +496,10 @@ function(arrayUtil, kernel, declare, listen, has, miscUtil, TouchScroll, hasClas
}
return whenDone(rows);
},
-
+
+ _onRowsNotification: function(){
+ },
+
renderHeader: function(){
// no-op in a plain list
},
View
13 extensions/Pagination.js
@@ -202,7 +202,13 @@ function(_StoreMixin, declare, lang, Deferred, on, query, string, has, put, i18n
// reset to first page
this.gotoPage(1);
},
-
+ _onRowsNotification: function(rows){
+ if(rows.length > this.rowsPerPage || // too many rows
+ (rows.length < this.rowsPerPage && // or not enough rows
+ this._currentPage < Math.ceil(this._total / this.rowsPerPage))){ // and we aren't the last page
+ this.gotoPage(this._currentPage);
+ }
+ },
gotoPage: function(page, focusLink){
// summary:
// Loads the given page. Note that page numbers start at 1.
@@ -222,10 +228,7 @@ function(_StoreMixin, declare, lang, Deferred, on, query, string, has, put, i18n
r, loadingNode;
// remove any currently-rendered rows
- for(r in rows){
- grid.row(r.substr(substrLen)).remove();
- }
- grid._rowIdToObject = {};
+ grid.cleanup();
contentNode.innerHTML = "";
loadingNode = put(contentNode, "div.dgrid-loading");
View
4 test/extensions/Pagination.html
@@ -87,6 +87,7 @@
}, "grid2");
window.gridfromhtml = new (declare([GridFromHtml, Keyboard, Selection, Pagination]))({
+ noDataMessage: "No data!",
store: testStore
}, "gridfromhtml");
@@ -136,7 +137,8 @@
<button onclick="grid.set('columns', getColumns());">Original</button>
<button onclick="grid.set('store', emptyStore);">Set to empty store</button>
<button onclick="grid.set('store', testStore);">Set to original store</button>
- <button onclick="testStore.add({col1:'new', col2:true});">Add row to original store</button>
+ <button onclick="testAsyncStore.remove(5);">Delete row 6 from original store</button>
+ <button onclick="testAsyncStore.add({col1:'new', col2:true});">Add row to original store</button>
<button onclick="grid.set('showFooter', !grid.get('showFooter'));">Toggle footer</button>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.