向dojo树的存储区添加新项不会触发更新



我正在尝试向dijit添加一个新节点。通过将节点添加到其存储中。节点被添加到存储中,但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();
    });
}

我做错了什么?

编辑上面的代码工作,它只是一个更新问题

try

store.newItem(item);
store.save();
theGrid.setStore(store);
theGrid.update();
theGrid._refresh();

最新更新