#10900 closed defect (fixed)
Tree: can't set path attribute to the root of the tree
Reported by: | yveskurz | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.6 |
Component: | Dijit | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
It's not possible to set the path of a dijit.Tree to the root of the tree.
For example: path = [ myStore.getRoot() ];
myTree.attr ('path', path);
This will fail because:
- myTree._setPathAttr() will remove the root item from path.(path now empty)
- myTree._setPathAttr() expands the root node and adds a callback to advance.
- advance() will be called back.
- advance() shifts the next item from path -> item = undefined
- since item is not a string it will try to get the identity from the model->store.
- this fails because item is undefined.
I think the problem is in 2) and can be solved by only adding a callback if path still contains elements. e.g instead of
this._expandNode(node).addCallback(dojo.hitch(this, advance));
possible (untested) solution:
var deferred = this._expandNode(node); if (path.length) { deferred.addCallback(dojo.hitch(this, advance)); }
Change History (4)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Milestone: | tbd → 1.6 |
---|---|
Owner: | set to bill |
Summary: | Dijit.Tree: setting path attribute to the root of the tree → Tree: can't set path attribute to the root of the tree |
Can reproduce the problem in test_Tree.html, doing:
dijit.byId("mytree").set("path", ["continentRoot"])
It gets stuck because the _setPathAttr() code is expecting at least two items in the array.
comment:3 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 Changed 10 years ago by
Thanks, I patched my Tree.js with this revision and it fixed this problem exactly as advertised. Awaiting its release in 1.5.1?
httpete
Note: See
TracTickets for help on using
tickets.
I'm not sure, but I think your are wrong and this is not a bug. You can set the path to the root, but the path attribute expects an array with strings e.g. myTree.attr('path', /) or whatever the rootId of your tree is when you declared the model. Your myStore.getRoot() returns undefined? since there is no store.getRoot(). There is a model.getRoot(), which expects an onItem callback.