Completed
Last Updated: 14 Jun 2018 14:45 by Patrick
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;
}
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
3 comments
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.