diji.Tree + JsonRestStore - 选择节点编程与tree.set("路径" [英] diji.Tree + JsonRestStore - selecting node programmatically with tree.set("path"

查看:116
本文介绍了diji.Tree + JsonRestStore - 选择节点编程与tree.set("路径"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题。我使用的是与dojox.data.JsonRestStore dijit.Tree作为数据源。所有节点都延迟加载。当我尝试使用tree.set以编程方式选择一个节点(路径,[1,2]),我得到一个错误说无法在不确定的扩张路径

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"

时有可能使用tree.set(路径...)时,树结构正在被动态装载

Is it possible to use tree.set("path"...) when the tree structure is being loaded dynamically ?

我的code包含2个文件。 source.php是数据源的实施

My code contains 2 files. source.php is the implementation of data source

  1. tree.php可以在这里找到 http://jsfiddle.net/hd2MZ/2/

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

source.php可以在这里找到 http://jsfiddle.net/6zu3d/

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

请帮忙:)

推荐答案

我看到一对夫妇潜在的问题...

I see a couple potential issues...

  1. 您需要指定起根节点的路径所需的节点。
  2. 您正在使用的 ForestStoreModel 初始化模式,在 ForestStoreModel 按当它创建在幕后根节点,因为你没有指定ID为根节点默认情况下将使用的$根$ 的作为ID的根节点。
  3. 我相信ID的数据存储中的项目都串......不是整数。
  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']);

这篇关于diji.Tree + JsonRestStore - 选择节点编程与tree.set("路径"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆