【问题标题】:dijit.Tree set paths JsonRestStore + ForestStoreModeldijit.Tree 设置路径 JsonRestStore + ForestStoreModel
【发布时间】:2013-11-23 14:27:44
【问题描述】:

我有一个 JsonRestStore + ForestStoreModel 树,它工作正常,但是当我尝试使用 tree.set('paths', ...) 函数直接访问节点时它不起作用。

请参考这个小例子:http://wasmonitor.com/dojotree.html

如果您单击该按钮,它应该展开 Web 服务器并选择 web1,但它没有...这是我的问题。

我的树是无根的,我知道 ForestStoreModel 在未指定时默认 rootId 为 $root$。所以我正在尝试使用以下代码访问节点:

    var stree = dijit.byId("statTree");
    stree.set("paths",  [ "$root$", "WebServers", "web1" ]);

但它永远不会打开。

已经读过这个问题:diji.Tree + JsonRestStore - selecting node programmatically with tree.set("path",这很相似,但对我不起作用...

有什么提示吗?

谢谢!

理查德

【问题讨论】:

    标签: tree dojo dijit.tree


    【解决方案1】:

    发现路径和路径设置完全不同。 path 接受单个路径作为数组,paths 接受数组数组。此外,我依赖 $root$ 作为默认的 rootId,但要使其正常工作,我必须在 ForestStoreModel 声明中指定一个 rootId。之后,正确的语法是:

        var stree = dijit.byId("statTree");
        stree.set("path",  [ "statTree", "WebServers", "web1" ]);
    

    或

        var stree = dijit.byId("statTree");
        stree.set("paths",  [[ "statTree", "WebServers", "web1" ]]);
    

    感谢 Sam 通过电子邮件向我指出这一点!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-30
      • 2016-05-24
      • 2012-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多