javascriptdojodijit.tree

dijit.Tree Folders appear with a icon PLUS even if no children are present


I am using the following code to render a dijit.Tree, as you can see from the picture I have these issues:

Could you please tell me what am I doing wrong here?

   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();

enter image description here


Solution

  • This is due to the method mayHaveChildren of the model.
    You have to override this method to make it "smarter"... See : https://dojotoolkit.org/documentation/tutorials/1.6/store_driven_tree/

    mayHaveChildren(object) - Indicates whether or not an object may have children (prior to actually loading the children)

    You can refer to this for an example:
    Dijit Tree filtering and search not working on ObjectStoreModel