Created
August 23, 2013 04:47
-
-
Save alanland/6315636 to your computer and use it in GitHub Desktop.
Dojo Tree.refresh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(["dojo/_base/lang", "dijit/Tree"], function(lang, Tree){ | |
lang.extend(Tree, { | |
refresh : function() { | |
// Destruct the references to any selected nodes so that | |
// the refreshed tree will not attempt to unselect destructed nodes | |
// when a new selection is made. | |
// These references are contained in Tree.selectedItem, | |
// Tree.selectedItems, Tree.selectedNode, and Tree.selectedNodes. | |
this.dndController.selectNone(); | |
this.model.store.clearOnClose = true; | |
//this.model.store.close(); | |
// Completely delete every node from the dijit.Tree | |
this._itemNodesMap = {}; | |
this.rootNode.state = "UNCHECKED"; | |
this.model.root.children = null; | |
// Destroy the widget | |
this.rootNode.destroyRecursive(); | |
// Recreate the model, (with the model again) | |
this.model.constructor(dijit.byId("myTree").model) | |
// Rebuild the tree | |
this.postMixInProperties(); | |
this._load(); | |
} | |
}); | |
}); | |
// then you can call | |
tree.refresh(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment