New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Implement findNodesByAttribute Method
Usually, the findNode client-side methods (findNodeByText, findNodeByValue, findNodeByAttribute) return the first node that satisfies the search criterion.
Below is the implementation of a function which returns an array of nodes having the same value of a particular attribute:
JavaScript
function findNodesByAttribute(tree, attribute, value) {
var nodes = tree.get_allNodes();
var result = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.get_attributes().getAttribute(attribute) == value) {
Array.add(result, node);
}
}
return result;
}
Here is a simple call to that function:
JavaScript
var tree = $find("<%= RadTreeView1.ClientID %>");
var nodes = findNodesByAttribute(tree, "readonly", "true");
for (var i = 0; i < nodes.length; i++) {
alert(nodes[i].get_text());
}