0

Below is my JSON. I'm trying to create a tree out of this, I tried with the following snippet:

require(["dijit/Tree", "dojo/data/ItemFileReadStore", "dijit/tree/ForestStoreModel", "dojo/domReady!"],
        function(Tree, ItemFileReadStore, ForestStoreModel){
    var store = new ItemFileReadStore({
        url: "/om/web/em/tree.json"
 });

    var treeModel = new ForestStoreModel({
        store: store,
        query: {id: 'aid'},
        rootId: "PSS-32",
        rootLabel: "P",
        childrenAttrs: ['eqList']
    });

    var myTree = new Tree({
        model: treeModel
    }, "treeOne");
    myTree.startup();
});

But this is giving me error loading PSS010010026024 children and message: "Cannot read property 'length' of undefined errors,what should be specified in the rootID,rootLabel and childrenAttrs?

[
        {
        "responseStatus": null,
        "entityType": "NODE",
        "aid": "p",
        "id": "p",
        "hsa": null,
        "eqList":[ {
        "responseStatus": null,
        "EId": "5",
        "EGroupId": "1006",
        "aid": "p",
        "additionalInfo": null,
        "eqList": [
        {
        "responseStatus": null,
        "EId": null,
        "EGroupId": null,
        "aid": null,
        "additionalInfo": null,
        "eqList": null,
        "shelfType": null,
        "isEqAvailable": null,
        "id": null,
        "entityType": null,
        "hsa": null,
        "Elist": null
        }
        ],
        "shelfType": null,
        "isEqAvailable": null,
        "id": "p/p",
        "entityType": "E",
        "hsa": "-",
        "Elist": null
        {
        "responseStatus": null,
        "EId": "5",
        "EGroupId": "1006",
        "aid": "p#OCS",
        "EType": "1830pss-ocs",
        "ERelease": "7.0",
        "additionalInfo": null,
        "eqList": [
        {
        "responseStatus": null,
        "EId": null,
        "EGroupId": null,
        "aid": null,
        "EType": null,
        "ERelease": null,
        "additionalInfo": null,
        "eqList": null,
        "shelfType": null,
        "isEqAvailable": null,
        "id": null,
        "entityType": null,
        "hsa": null,
        "Elist": null
        }
        ],
        "shelfType": null,
        "isEqAvailable": null,
        "id": "p/p#OCS",
        "entityType": "E",
        "hsa": "-",
        "Elist": null
        }
        ]
        }
        ]
user3271040
  • 79
  • 1
  • 1
  • 8

1 Answers1

0

The rootID attribute is what ID you want to give the root item that will be created (so that you can query for it later or check if your tree is at the top level). The rootLabel is what you want the label of the root attribute to be. The childrenAttrs is how you tell the Tree where a specific node's children are.

I'm not sure what you're trying to do in your code though since your data doesn't seem to have PSS010010026024 in it but I would recommend checking out the API documentation for the ForestTreeModel here: http://dojotoolkit.org/api/?qs=1.9/dijit/tree/ForestStoreModel

Richard
  • 1,138
  • 1
  • 6
  • 11