我无法创建第三级dijit.Tree

时间:2011-10-24 08:08:21

标签: json tree dojo

我想创建一个3级dijit.Tree,就像那样:

-root
|
--level1
 |
 --level2

我认为这很简单,因为this tutorial中有一段代码片段(例1)。但不知怎的,我设法失败了。 这是我的dojo代码(变量名是波兰语,我希望它不是问题):

modelRaportow = new dijit.tree.ForestStoreModel({
    store: new dojo.data.ItemFileReadStore({
        url: "logika/getJSON/getStatusRaportow.php"
    }),
    query: {typ: 'galaz'},
    rootId: 'statusRaportuRoot',
    rootLabel: 'Status raportu',
    childrenAttrs: 'raporty'
});

drzewoRaportow = new dijit.Tree({
    openOnClick: true,
    model: modelRaportow,
    showRoot: true,
    persist: false
}, "target-status-raportow");

drzewoRaportow.startup();

这是logika/getJSON/getStatusRaportow.php返回的我的JSON(同样,名字是波兰语):

{
    "identifier":"id",
    "label":"status",
    "items": [
        {"id":0,"status":"zaakceptowane","typ":"galaz"
            "raporty":[{"_reference":1},{"_reference":2},{"_reference":3}]},
                {"id":1,"data":"24-10-2011","wykonujacy":"cblajszczak","idKlienta":3,"status":"Raport0","typ":"lisc"},
                {"id":2,"data":"24-10-2011","wykonujacy":"cblajszczak","idKlienta":1,"status":"Raport1","typ":"lisc"},
                {"id":3,"data":"24-10-2011","wykonujacy":"cblajszczak","idKlienta":3,"status":"Raport2","typ":"lisc"},
        {"id":4,"status":"odrzucone","typ":"galaz"
            "raporty":[{"_reference":5},{"_reference":6},{"_reference":7}]},
                {"id":5,"data":"24-10-2011","wykonujacy":"cblajszczak","idKlienta":1,"status":"Raport3","typ":"lisc"},
                {"id":6,"data":"24-10-2011","wykonujacy":"cblajszczak","idKlienta":3,"status":"Raport4","typ":"lisc"},
                {"id":7,"data":"24-10-2011","wykonujacy":"cblajszczak","idKlienta":3,"status":"Raport5","typ":"lisc"}
]}

最后,这就是我得到的:img - 查询返回的根节点和lvl 1节点,没有子节点。

问题是 - 我的错误在哪里?有谁能看到它?

2 个答案:

答案 0 :(得分:4)

typraporty值对之间没有逗号。

答案 1 :(得分:1)

我有一个部分答案:通过在类似情况下单步执行代码,我发现它希望childrenAttrs成为一个数组,所以它应该是:

childrenAttrs: ['raporty']

但我仍然无法在我的案例中出现第三级。