繁体   English   中英

Dojo-Dijit.Tree-更新树

[英]Dojo - Dijit.Tree - Updating Tree

我创建了一个基于TreeStoreModel的简单树,该树由ItemFileWriteStore支持。 我尝试通过删除存储并将其添加到商店中来更新树,如下所示,但是没有。

dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dijit.Tree");
dojo.addOnLoad(function () {
    var tmpData = [{
            "name" : "Dell",
            "type" : "business",
            "businessid" : "1",
            "projectid" : "1",
            "submenu" : [{
                    "name" : "OTP",
                    "type" : "product",
                    "productid" : "100"
                }
            ]
        }
    ];

    var tmpData1 = [{
            "name" : "Lenovo",
            "type" : "business",
            "businessid" : "1",
            "projectid" : "1",
            "submenu" : [{
                    "name" : "OTP",
                    "type" : "product",
                    "productid" : "100"
                }
            ]
        }
    ];
    var store = new dojo.data.ItemFileWriteStore({
            data : {
                label : 'name',
                items : tmpData
            }
        });

    var treeModel = new dijit.tree.TreeStoreModel({
            store : store,
            query : {
                type : 'business'
            },
            childrenAttrs : ["submenu"]

        });

    var divTestTree = dojo.create("div", null, dojo.body(), "first");
    var mytree = new dijit.Tree({
            model : treeModel
        },
            divTestTree);
    /* Tree is created at this point */

    /* Delete the item from the store,  for some reason tempData is being reset*/
    store.deleteItem(tmpData[0]); 
    /* save */
    store.save();
    /* Tree shows up no more at this point */

    /* Try adding new item to the store */
    store.newItem(tmpData1[0]);
    /* save */
    store.save();
    /*nothing happens! */   
});

我从这里开始 ,我一定在这里缺少一些琐碎的东西。 请帮忙。

对于任何来这里寻求解决方案的人,“我怀疑存在错误”是我在论坛中获得的唯一答案,所以可能这是一个错误-goo.gl/M7xg7

取自该页面

如何从商店刷新树?

不支持此功能。 存储需要将对数据的任何更改通知树。 当前,这实际上仅由dojo.data.ItemFileWriteStore支持(开箱即用),因为设置客户端-服务器dojo.data源时,只要数据发生更改,服务器就会在通知客户端时通知客户端,这超出了范围dojo,这是一个仅用于客户端的解决方案。

更新树的唯一方法是再次重画它:(

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM