Search in treeview

2 posts, 0 answers
  1. Pelli
    Pelli avatar
    11 posts
    Member since:
    May 2014

    Posted 23 Jun 2015 Link to this post

    Hi,

    I have a treeview with nodes populated with only strings. Attached the node structure. Now, how can I acheive search capability through recursive search in node structure. I have gone through http://docs.telerik.com/devtools/wpf/controls/radtreeview/how-to/bring-path-into-view, but this uses index mechanism and only for numericals.

     

    Any suggestions on how to search for a string in recursive and bring into path. Please provide your inputs.

    Thanks,

    Subhashini

     

     

     

  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 25 Jun 2015 Link to this post

    Hello Pelli,

    The treeview does not expose recursive search out of the box. It is also harder to search recursively when the virtualization is enabled. I believe you have a data bound scenario. What I would suggest here is to use a Dictionary to keep track on your items and the appropriate path they have. For instance a Dictionary<string, string> will be ideal for this purpose as your nodes are populated with only strings.

    For example let's assume we are having a tree like:
    A
       A1
       A2
    B
       B1
       B2
    C
       C1
    If you search for "B1", that same key will have a value path "B//B1" in your dictionary and it will bring this very path into view. Following this approach you will have a predefined Dictionary with the appropriate keys that can be later used for the search.

    Furthermore keep in mind that the BringPathIntoView() method will work properly only if you set the TextSearch.TextPath attached property. This is due to the fact that the method internally uses the TextPath value to match every part of the path to corresponding property value from the business object / (or radtreeeviewitem in non databound tree).

    Hope this helps.

    Regards,
    Peshito
    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 WPF is Visual Studio 2017 Ready
Back to Top