0

下面是我的 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();
});

但这给了我加载 PSS010010026024 孩子和消息时出错:“无法读取未定义错误的属性‘长度’,应该在 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
        }
        ]
        }
        ]
4

1 回答 1

0

rootID 属性是您要为将要创建的根项目提供的 ID(以便您稍后可以查询它或检查您的树是否位于顶层)。rootLabel 是您希望根属性的标签。childrenAttrs 是您告诉 Tree 特定节点的子节点在哪里的方式。

我不确定您要在代码中执行什么操作,因为您的数据中似乎没有 PSS010010026024,但我建议您在此处查看 ForestTreeModel 的 API 文档:http: //dojotoolkit.org/ api/?qs=1.9/dijit/tree/ForestStoreModel

于 2014-04-22T19:22:16.743 回答