0

我正在使用以下代码来渲染 dijit.Tree,从图片中可以看出我有这些问题:

  • 该文件夹标有“加号图标”,但任何节点都不存在子级。
  • 如果我点击一个文件夹,“加号图标”就会消失(首先不应该在那里)。

你能告诉我我在这里做错了什么吗?

   this._tree = new Tree({
        model: this._model,
        showRoot: false,
        autoExpand: false,
        persist: false,
        getLabel: function (item) {
            return item.name;
        }
    });
    this._tree.placeAt(this.node);
    this._tree.startup();

在此处输入图像描述

4

1 回答 1

1

这是由于mayHaveChildren模型的方法。
您必须重写此方法以使其“更智能”...请参阅:https ://dojotoolkit.org/documentation/tutorials/1.6/store_driven_tree/

mayHaveChildren(object) - 指示一个对象是否可能有孩子(在实际加载孩子之前)

您可以参考此示例:
Dijit Tree filtering and search not working on ObjectStoreModel

于 2015-10-08T14:29:36.763 回答