如何从JSON创建树[森林树模型].



下面是我的JSON。我正试图用这个创造一棵树,我尝试了以下片段:

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

但这给了我加载PSS10010010026024子项的错误,并显示消息:"无法读取未定义错误的属性'length',应该在rootID、rootLabel和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
        }
        ]
        }
        ]

rootID属性是您想要为将要创建的根项目提供的ID(这样您以后就可以查询它或检查您的树是否处于顶级)。rootLabel是你想要的根属性的标签。childrenAttrs是你告诉树特定节点的子节点在哪里的方式。

我不确定你在代码中试图做什么,因为你的数据中似乎没有PSS1001000026024,但我建议你在这里查看ForestTreeModel的API文档:http://dojotoolkit.org/api/?qs=1.9/dijit/tree/ForestStoreModel

相关内容

  • 没有找到相关文章

最新更新