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

Text search in sibling nodes

3 Answers 207 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 11 Jan 2013, 07:47 AM
I've enabled the text search capability with setting IsTextSearchEnabled to true. This works fine, when searching children nodes of the currently selected node. However, the text search does not jump to the next sibling node if the text is not being found in the current node. Is there any way to force searching in the sibling nodes?

Example:
If the current node is "A" a text search for "A1" will be successfull, but searching for "B1" fails.
     - A
            A1
            A2
    - B
            B1
            B2
  
Thanks,
Michael

3 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 16 Jan 2013, 10:02 AM
Hello Michael,

I'm not really sure how you implement your searching logic but the RadTreeView has a few built-in methods that can be used to bring an item into view based on its Header content or data context.

I attached a sample solution demonstrating how you can search through the data displayed inside the control as well as how to filter or sort it. The main method used to bring a searched item into view is the RadTreeViewItem.BringIntoView() method. Another useful method is the RadTreeView.BringPathIntoView() method described here. With both approaches you need to set the TextSearch.TextPath attached property in the RadTreeView definition to indicate which business property will be used as a path segment while searching through the RadTreeViewItems:
<telerik:RadTreeView x:Name="radTreeView" Grid.Row="1" Grid.ColumnSpan="3"
        telerik:TextSearch.TextPath="Name"
        Padding="10" Margin="0 0 1 0"
        ItemsSource="{StaticResource SampleDataSource}"
        ItemTemplate="{StaticResource CategoryTemplate}"
        ItemPrepared="radTreeView_ItemPrepared" />

Please take a look at the solution and let me know if it helps or if I'm missing something.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Michael
Top achievements
Rank 1
answered on 16 Jan 2013, 02:16 PM
Hello Tina,

in your example the property IsTextSearchEnabled isn't set to true. Therefore the automatic text search while typing doesn't work at all. Instead your searching via clicking on a button. In the button's event handler you've implemented your own search logic; this works with sibling nodes, but it has nothing to do with the built-in text search capability of RadTreeView.

Regards,
Michael
0
Tina Stancheva
Telerik team
answered on 16 Jan 2013, 04:59 PM
Hello Michael,

I'm sorry for misunderstanding you. Unfortunately the RadTreeView doesn't support the feature you have in mind. You can see the IsTextSearchEnabled property as both the RadTreeView and the RadTreeViewItem controls derive from an ItemsControl. And the functionality you get is actually inherited from the ItemsControl implementation but as it isn't extended nor configured to specifically work with the RadTreeView control, it doesn't work as you expect.

Instead, you'll have to implement a custom logic for this scenario following the approach described in the sample solution I sent. For example, you can move the Search button on-click logic in the RadTreeView.KeyDown event handler and modify it to better fit your requirements.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeView
Asked by
Michael
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Michael
Top achievements
Rank 1
Share this question
or