Completed
Last Updated: 01 Apr 2019 07:30 by ADMIN
ADMIN
Hristo
Created on: 07 Jun 2018 11:45
Category: TreeView
Type: Feature Request
1
FIX. RadTreeView - the filter predicate should be called on all nodes in the tree when custom filtering is used
At the moment the filter predicate is called only for the root nodes. A possible workaround is to recursively apply the filter logic for the child nodes as well.
Workaround:
private void Button1_Click(object sender, EventArgs e)
{
    this.radTreeView1.TreeViewElement.FilterPredicate = this.FilterNode;
    this.radTreeView1.Filter = "Custom";
}

private bool FilterNode(RadTreeNode node)
{
    Console.WriteLine(node.Text);
    if (node.Text.Contains("Child: 3"))
    {
        return true;
    }

    Stack<RadTreeNode> children = new Stack<RadTreeNode>();
    if (node.Nodes.Count > 0)
    {
        children.Push(node);
        while (children.Count > 0)
        {
            RadTreeNode current = children.Pop();
            foreach (RadTreeNode child in current.Nodes)
            {
                if (child.Text.Contains("Child: 3"))
                {
                    return true;
                }

                children.Push(child);
            }
        }
    }

    return false;
}
7 comments
ADMIN
Hristo
Posted on: 01 Apr 2019 07:30
Hi Kjartan,

You can search for a node using the Find method of the tree. Then you can iterate the parent nodes and set their Expanded property to true
RadTreeNode node = this.radTreeView1.Find("Person1");
if (node != null)
{
    node.Expanded = true;
    RadTreeNode parent = node.Parent;
    while (parent != null)
    {
        parent.Expanded = true;
        parent = parent.Parent;
    }
}

I hope this will help. On a side note, please also consider using the ticketing system or the forums for questions which are not directly related with an item logged on the feedback portal. Thank you for understanding.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Kjartan
Posted on: 28 Mar 2019 11:03

Hi, thanks for the heads up on that.

 

However, if i search for a child node, i would like all nodes to be expanded down to that node, how would i do that?

ADMIN
Hristo
Posted on: 28 Mar 2019 06:50
Hello Kjartan,

The issue was fixed in the R2 2018 SP1 version of the controls. There is another issue related to this one which was fixed in the R3 2018 SP1 version. In case you keep experiencing the incorrect behavior with the latest version, please open up a support ticket with details on how it can be reproduced.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Kjartan
Posted on: 27 Mar 2019 14:56

Hi,

This is extremely weird behaviour, if we search a tree that look like this:

 

Customers

Cust1

Person1

Person2

Cust2

 

And if i search in a textbox for Person2, i start typing "Per..", then it certainly wouldn't match the Customers or the Cust1 node, so it never searches for Person2. Seems like a flawed behaviour. Has this changed in a new version?

 

Thanks

Patrick
Posted on: 08 Jun 2018 12:30
Thanks.  After testing your work around, things are good now.  Thanks for the help.  Weird to think no one else has seen this before.
ADMIN
Hristo
Posted on: 08 Jun 2018 07:14
Hi Patrick,

The current incorrect behavior is such that if you don`t have a match on any of the parent levels the predicate will not be called for the child nodes if such exist. If there is a match on the parent level the filter function will be called on the child nodes as well. Once the issue is resolved the predicate will be called on all nodes.

Regards,
Hristo
Patrick
Posted on: 07 Jun 2018 15:08
I am the one that reported this issue.  Seems strange that looks in child record for normal filtering but for custom it does not.  I had to follow a sample I believe you did before to set the tag for each nodes that matches first to true and then check for true in filter function.  Had to recursively go back up to parent level to set to true also.  Seems like custom search looks in top level and if top level doesn't match, it doesn't look at children to check either.

You sample looks like it will never get to the child nodes of a parent node that matches unless it will then search the child nodes since the parent node matches.

As I side note, I also made my search do a wild card to see if the node text matches any word in my search text not just an exact match.  I do a .Any filter on a string array and returns true if node text matches any words in array.

Thanks for this suggestion.