This is a migrated thread and some comments may be shown as answers.

Searching - Return node collection or array

1 Answer 35 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Developer
Top achievements
Rank 1
Developer asked on 28 Jan 2016, 02:09 PM
Hi,
I have radtreeview control which has been bound with data.  I’ve like to search all the nodes (server side) and return all those with a specific attribute.
I tried findbyattribute but this only returns a single node.  I’ve like to return a collection of nodes?
Any idea how this can be accomplished please?

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 02 Feb 2016, 11:07 AM
Hello,

You can create a method which will check each node in the TreeView's NodeCollection and if it has an attribute with a specific value it will be added to a collection. For example:
GetNodesWithAttributeValue("test", "123");

private List<RadTreeNode> GetNodesWithAttributeValue(string attr, string attrValue)
{
    List<RadTreeNode> nodes = new List<RadTreeNode>();
    foreach (RadTreeNode node in RadTreeView1.GetAllNodes())
    {
        if (node.Attributes[attr] == attrValue)
        {
            nodes.Add(node);
        }
    }
    return nodes;
}

Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
Developer
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or