RC_ants
14 Aug 2008, 11:57 PM
To be able to process a number of actions on to a tree with users (dissable a team, uncheck a team when another team is selected) I need to have all the node objects which contain additional attribute to make them identifialble.
To retrieve all these nodes I have written this code. (fRootNode is the rootnode of the tree I need the nodes from)
retrieveAllChildNodes:function(fRootnode,next) {
if (typeof next == "undefined") {
foundNodes = new Array();
}
if(fRootnode.hasChildNodes()){
childNodes = fRootnode.childNodes;
for (var i = 0; i < childNodes.length; i++) {
foundNodes[foundNodes.length]=childNodes[i];
this.retrieveAllChildNodes(childNodes[i],1);
}
}
return foundNodes;
}
It does retrieves the first childs of the first 4 levels and all the users of the level 4 team, but the rest of the teams on level 4 and their users are not added.
I would be pleased to learn if their is a more simple way to retrieve all the nodes in to 1 single dimensional array.
To retrieve all these nodes I have written this code. (fRootNode is the rootnode of the tree I need the nodes from)
retrieveAllChildNodes:function(fRootnode,next) {
if (typeof next == "undefined") {
foundNodes = new Array();
}
if(fRootnode.hasChildNodes()){
childNodes = fRootnode.childNodes;
for (var i = 0; i < childNodes.length; i++) {
foundNodes[foundNodes.length]=childNodes[i];
this.retrieveAllChildNodes(childNodes[i],1);
}
}
return foundNodes;
}
It does retrieves the first childs of the first 4 levels and all the users of the level 4 team, but the rest of the teams on level 4 and their users are not added.
I would be pleased to learn if their is a more simple way to retrieve all the nodes in to 1 single dimensional array.