Searching - Return node collection or array

2 posts, 0 answers
  1. Developer
    Developer avatar
    38 posts
    Member since:
    Apr 2014

    Posted 28 Jan Link to this post

    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?
  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 02 Feb Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top