Permalink
Browse files

Merge branch 'rest' into adjust-selection-after-delete

  • Loading branch information...
2 parents b33b17b + f1e8a2a commit 3aa3e1295575270d19ff1d31b206533e046ff886 @kriszyp committed Feb 23, 2012
Showing with 26 additions and 7 deletions.
  1. +12 −5 OnDemandList.js
  2. +14 −2 test/JsonRest.html
View
@@ -56,9 +56,13 @@ return declare([List, _StoreMixin], {
var priorPreload = this.preload;
if(priorPreload){
// the preload nodes (if there are multiple) are represented as a linked list, need to insert it
- if((preload.next = priorPreload.next)){
+ if((preload.next = priorPreload.next) &&
+ // check to make sure that the current scroll position is below this preload
+ this.bodyNode.scrollTop >= priorPreload.node.offsetTop){
+ // the prior preload is above/before in the linked list
preload.previous = priorPreload;
}else{
+ // the prior preload is below/after in the linked list
preload.next = priorPreload;
preload.previous = priorPreload.previous;
}
@@ -106,7 +110,7 @@ return declare([List, _StoreMixin], {
return trs;
});
});
-
+
// return results so that callers can handle potential of async error
return results;
},
@@ -242,10 +246,14 @@ return declare([List, _StoreMixin], {
if(visibleBottom + mungeAmount < preloadTop){
// the preload is below the line of sight
- preload = preload.previous;
+ do{
+ preload = preload.previous;
+ }while(preload && !preload.node.offsetParent); // skip past preloads that are not currently connected
}else if(visibleTop - mungeAmount > (preloadTop + (preloadHeight = preloadNode.offsetHeight))){
// the preload is above the line of sight
- preload = preload.next;
+ do{
+ preload = preload.next;
+ }while(preload && !preload.node.offsetParent);// skip past preloads that are not currently connected
}else{
// the preload node is visible, or close to visible, better show it
var offset = ((preloadNode.rowIndex ? visibleTop : visibleBottom) - preloadTop) / grid.rowHeight;
@@ -322,7 +330,6 @@ return declare([List, _StoreMixin], {
put(loadingNode, "div.dgrid-" + (below ? "below" : "above"), grid.loadingMessage);
// use the query associated with the preload node to get the next "page"
options.query = preload.query;
-
// Query now to fill in these rows.
// Keep _trackError-wrapped results separate, since if results is a
// promise, it will lose QueryResults functions when chained by `when`
View
@@ -24,18 +24,30 @@
<script type="text/javascript">
require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", "dgrid/Editor", "dgrid/Keyboard", "dgrid/Tree", "dojo/_base/declare", "dojo/store/JsonRest", "dojo/store/Observable", "dojo/store/Cache", "dojo/store/Memory", "dojo/domReady!"],
function(List, Grid, Selection, Editor, Keyboard, Tree, declare, JsonRest, Observable, Cache, Memory){
- var testStore = Observable(Cache(JsonRest({target:"./data/rest.php", idProperty: "id"}), Memory()));
+ var testStore = Observable(Cache(JsonRest({
+ target:"./data/rest.php?",
+ idProperty: "id",
+ query: function(query, options){
+ // have to manually adjust the query to get rid of the double ?? that trips php up
+ if(query.parent){
+ query = "parent=" + query.parent;
+ }
+ return JsonRest.prototype.query.call(this, query, options);
+ }
+ }), Memory()));
testStore.getChildren = function(parent, options){
return testStore.query({parent: parent.id}, options);
};
var columns = [
Tree({label:'Name', field:'name', sortable: false}),
{label:'Id', field:'id', sortable: false},
- Editor({label:'Comment', field:'comment', sortable: false}, "text")
+ Editor({label:'Comment', field:'comment', sortable: false}, "text"),
+ Editor({label:'Boolean', field:'boo', sortable: false, autoSave: true}, "checkbox")
];
window.grid = new (declare([Grid, Selection, Keyboard]))({
store: testStore,
+ getBeforePut: false,
columns: columns
}, "grid");
deleteSelected = function(){

0 comments on commit 3aa3e12

Please sign in to comment.