简体   繁体   English

dijit.Tree:在pasteItem调用之后如何更新树?

[英]dijit.Tree: How to update tree after pasteItem call?

I have a custom implementation of a tree model for a file explorer tree. 我有一个文件浏览器树的树模型的自定义实现。 This tree should also support drag n drop, so I wrote the pasteItem method of my tree as follows: 该树还应该支持drag n drop,因此我将树的pasteItem方法编写如下:

pasteItem: function(childItem, oldParentItem, newParentItem, bCopy){
    var oldParentItemFiles = new Array();
    for(var idx in oldParentItem.files) {
        if(oldParentItem.files[idx].name != childItem.name) {
            oldParentItemFiles.push(oldParentItem.files[idx]);
        }
    }

    newParentItem.files.push(childItem);
    childItem.parent = newParentItem;
}

I debugged the function and as far as I could see the variables are modified correctly. 我调试了该函数,据我所知,变量已正确修改。 However, the function is properly called and runs without an error, also the drag-n-drop dialog is shown but the tree does not change. 但是,该函数已正确调用并运行且没有错误,并且显示了拖放对话框,但树未更改。

Is there something like a render() method that I have to call after? 是否需要像render()方法这样的东西?

I found the answer: 我找到了答案:

The tree connects to the onChildrenChange, onChange and onDelete events of the model. 该树连接到模型的onChildrenChange,onChange和onDelete事件。 So, just call these methods on the model tree with the appropriate values and it will work. 因此,只需使用适当的值在模型树上调用这些方法,它将起作用。 If you implement the model yourself, be sure to change your model data ;) 如果您自己实施模型,请确保更改模型数据;)

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

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