Permalink
Browse files

Add support for async mayHaveChildren

  • Loading branch information...
1 parent 4b55763 commit 1613da3fc9e3f39456a321cee80bb115a0310dae @kriszyp committed May 30, 2012
Showing with 10 additions and 4 deletions.
  1. +10 −4 tree.js
View
14 tree.js
@@ -1,6 +1,7 @@
define(["dojo/_base/declare", "dojo/_base/Deferred", "dojo/query", "dojo/on", "dojo/aspect", "dojo/has!touch?./util/touch", "put-selector/put"],
function(declare, Deferred, querySelector, on, aspect, touchUtil, put){
+var when = Deferred.when;
return function(column){
// summary:
// Add a editing capability
@@ -19,12 +20,17 @@ return function(column){
var mayHaveChildren = !grid.store.mayHaveChildren || grid.store.mayHaveChildren(object);
// create the expando
var dir = grid.isRTL ? "right" : "left";
- var expando = put(td, "div.dgrid-expando-icon" + (mayHaveChildren ? ".ui-icon.ui-icon-triangle-1-e" : "") +
- "[style=margin-" + dir + ": " + (level * 19) + "px; float: " + dir + "]");
+ var expando = put(td, "div.dgrid-expando-icon[style=margin-" +
+ dir + ": " + (level * 19) + "px; float: " + dir + "]");
expando.innerHTML = " "; // for opera to space things properly
originalRenderCell.call(this, object, value, td, options);
expando.level = level;
- expando.mayHaveChildren = mayHaveChildren;
+ when(mayHaveChildren, function(mayHaveChildren){
+ if(mayHaveChildren){
+ expando.mayHaveChildren = true;
+ put(expando, ".ui-icon.ui-icon-triangle-1-e");
+ }
+ });
var tr, query;
if(!grid.expand){
@@ -86,7 +92,7 @@ return function(column){
return grid.store.getChildren(row.data, options);
};
query.level = target.level;
- Deferred.when(
+ when(
grid.renderQuery ?
grid._trackError(function(){
return grid.renderQuery(query, preloadNode);

0 comments on commit 1613da3

Please sign in to comment.