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 fol开发者_JAVA技巧lows:
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 ;)
精彩评论