我试图通过将节点添加到其商店来向dijit.tree添加新节点。 该节点已添加到商店,但treeModel未更新。
这里是我的商店,模型和树的设置
this.treeStore = new dojox.data.JsonRestStore({
target:"dn/",
idAttribute:"serviceId",
labelAttribute:"name"
});
this.treeModel = new dijit.tree.ForestStoreModel({
store: this.treeStore,
rootLabel:'All Files',
deferItemLoadingUntilExpand: true,
mayHaveChildren:function(item){ return item.children != undefined && item.children.length>0},
childrenAttrs: ["children"]
});
this.docTree = new dijit.Tree({
id:"myTree",
showRoot:false,
model: this.treeModel,
persist: false,
},this.dijitTree);
这里添加项目的功能
function addNewNode(item){
var self=this;
console.log(item);
this.treeModel.getRoot(function(root){
var tmp=self.treeStore.newItem(item,{parent:root, attribute:[]});
self.treeStore.save();
});
}
我做错了什么?
修改 上面的代码告诉它只是一个更新问题
答案 0 :(得分:1)
试
store.newItem(item);
store.save();
theGrid.setStore(store);
theGrid.update();
theGrid._refresh();