But I need to get all nodes from WebDataTree by js
How I can get all nodes from WebDataTree by js?
Thanks, for you reply. We solve the problem.
Hello Anton,
I am still following your case. Have been able to resolve your issue?
If you still have any concerns or questions I would be glad to help.If you need any additional assistance do not hesitate to ask.
The iterators for the for loops had to be defined as variables in this case to ensure correct scoping. Here is the revised function:
function loopThroughNodes() { var tree = $find("<%= WebDataTree1.ClientID %>"); for (var i = 0; i < tree.getNodes().get_length(); i++) { var rootNode = tree.getNodes().getNode(i); recrusiveIteration(rootNode); } } function recrusiveIteration(node) { console.log(node.get_text()); if (node.hasChildren()) { for (var j = 0; j < node.getItems().get_length(); j++) { var child = node.getItems().getNode(j); recrusiveIteration(child); } } return; }
function loopThroughNodes() {
var tree = $find("<%= WebDataTree1.ClientID %>");
for (var i = 0; i < tree.getNodes().get_length(); i++) {
var rootNode = tree.getNodes().getNode(i);
recrusiveIteration(rootNode);
}
function recrusiveIteration(node) {
console.log(node.get_text());
if (node.hasChildren()) { for (var j = 0; j < node.getItems().get_length(); j++) {
var child = node.getItems().getNode(j);
recrusiveIteration(child);
return;
Feel free to contact me if you have ant further questions.
This solution dont work for such structure:
RootNode
-node1
--node11
---node111
-node12
--node121
-node2
-node3
when we get to the ---node111 it became infinite loop
Hello Anton Pridanov,
Do not hesitate to contact me if you have any additional questions concerning this matter.