Text search in sibling nodes

4 posts, 0 answers
  1. Michael
    Michael avatar
    34 posts
    Member since:
    Oct 2009

    Posted 11 Jan 2013 Link to this post

    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
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Jan 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Michael
    Michael avatar
    34 posts
    Member since:
    Oct 2009

    Posted 16 Jan 2013 Link to this post

    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
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Jan 2013 Link to this post

    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.

Back to Top