简体   繁体   中英

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:

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?

I found the answer:

The tree connects to the onChildrenChange, onChange and onDelete events of the model. 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 ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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