问题
I've this problem. I'm using dijit.Tree with dojox.data.JsonRestStore as datasource. All nodes are lazy loaded. When I try to programmatically select a node using tree.set("path", [1,2]) I get an error saying "Could not expand path at undefined"
Is it possible to use tree.set("path"...) when the tree structure is being loaded dynamically ?
My code contains 2 files. source.php is the implementation of data source
tree.php is available here http://jsfiddle.net/hd2MZ/2/
source.php is available here http://jsfiddle.net/6zu3d/
Please help :)
回答1:
I see a couple potential issues...
- You need to specify the path to the desired node starting at the root node.
- You are using the ForestStoreModel which creates a root node under the covers, since you did not specify the id for the root node when initializing the model, the ForestStoreModel by default will use '$root$' as the id for the root node.
- I believe id's for items in the data store are strings... not integers.
... where you are trying to set the path I would try the following:
tree.set("path", ['$root$', '1', '2']);
来源:https://stackoverflow.com/questions/11229201/diji-tree-jsonreststore-selecting-node-programmatically-with-tree-setpath