I'am trying to add a new node to a dijit.tree by adding the node to its store. The node is added to the store but the treeModel is not updated.
Here the setup of my store, model and tree
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);
Here the function which adds the item
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();
开发者_StackOverflow中文版 });
}
What am I doing wrong?
EDIT The above code woks it was just an update problem
try
store.newItem(item);
store.save();
theGrid.setStore(store);
theGrid.update();
theGrid._refresh();
精彩评论