diji.Tree + JsonRestStore - selecting node programmatically with tree.set(“path”

牧云@^-^@ 提交于 2019-12-08 01:08:45

问题


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

  1. tree.php is available here http://jsfiddle.net/hd2MZ/2/

  2. source.php is available here http://jsfiddle.net/6zu3d/

Please help :)


回答1:


I see a couple potential issues...

  1. You need to specify the path to the desired node starting at the root node.
  2. 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.
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!