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

Search in treeview

1 Answer 127 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Pelli
Top achievements
Rank 1
Pelli asked on 23 Jun 2015, 01:14 PM

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

 

 

 

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 25 Jun 2015, 08:38 AM
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
Tags
TreeView
Asked by
Pelli
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Share this question
or