But I need to get all nodes from WebDataTree by js
How I can get all nodes from WebDataTree by js?
Hello Anton Pridanov,
Thank you for posting in the community!
The count of all nodes in WebDataTree should be accesible by iterating through all the parent nodes and taking their children, for instance:
function loopThroughNodes() { var tree = $find("<%= webdatatree1="" clientid="">"); for(var i = 0; i < tree.getNodes().get_length(); i++) { var rootNode = tree.getNodes().getNode(i); recursiveIteration(rootNode); } } function recursiveIteration(node) { console.log(node.get_text()); if(node.hasChildren()) { for(var j = 0; j < node.getItems.get_lenght(); j++) { var child = node.getItems().getNode(j); recursiveIteration(child); } } }
function loopThroughNodes() {
var tree = $find("<%= webdatatree1="" clientid="">");
for(var i = 0; i < tree.getNodes().get_length(); i++) {
var rootNode = tree.getNodes().getNode(i);
recursiveIteration(rootNode);
}
function recursiveIteration(node) {
console.log(node.get_text());
if(node.hasChildren()) {
for(var j = 0; j < node.getItems.get_lenght(); j++) {
var child = node.getItems().getNode(j);
recursiveIteration(child);
I am also attaching a sample for your scenario using version 12.2.20122.2031 for you.
Do not hesitate to contact me if you need any further support.
Edit:Code Review
Do not hesitate to contact me if you have any additional questions concerning this matter.