Error in loading tree of dojo, error in loading tree of dojo
1. Error description
Error loading undefined children.
TypeError: this. _ arrayOfTopLevelItems is undefied.
2. Error cause
3. Solution
How can I expand all the nodes in the dojo tree when the page is opened?
A problem occurs: How to expand all nodes in the dojo tree? Because struts2 is the default dojo, what should I do if I want to implement dojo to expand all nodes at a time?
After turning around on google, I only asked questions and did not solve them. So I had to do it myself. Fortunately, after some brain cells struggled, I went out and shared it with everyone. I also accepted criticism from everyone:
Dojo. addOnLoad (function (){
Dojo. widget. byId ('treetestid ');
ExpandObj (myObj );
});
Function expandObj (obj ){
If (obj ){
If (obj. children ){
For (var I = 0; I <obj. children. length; I ++ ){
Var childObj = obj. children [I];
If (childObj ){
Try {
ChildObj. expand ();
} Catch (e ){
}
If (childObj. children ){
ExpandObj (childObj );
}
}
}
}
}
}
Click events in the dojo tree
You can operate a single node dijit/Tree. _ TreeNode or the entire Tree.
For more information, see the official dojo documentation. Dojotoolkit.org/api/
Open dijit --- Tree. Click in the document that appears on the right
Event Summary
All kinds of events have
Method Summary
There are also various methods for the tree.
See the dijit/Tree reference documentation for more information ..
Click it to see the detailed example. That is, dojotoolkit.org/..e.html.
All of them are very detailed. You do not need to refer to other articles after reading the documents.
By the way, if some browsers cannot run the sample program on the website, you can try another browser.