![](/img/trans.png)
[英]dojo dijit.tree getChildren() not returning all tree nodes
[英]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.