RadTreeView GetItemByPath

6 posts, 0 answers
  1. Rob
    Rob avatar
    11 posts
    Member since:
    Jul 2008

    Posted 22 Jul 2008 Link to this post

    I am currently using the RadTreeView to organize a list of unrelated items. As an example my top level consists of Projects and Contacts. Under the Projects node I have Owned, Monitored, and Participant nodes with LoadOnDemand enabled. Under each of those nodes I have project data nodes. When one of these nodes is selected an editable project detail form is diplayed. I would like to do the following:

    1. Mark the "context" of the currently selected item. For example, if a project is selected I would identify the Projects node as the context node.
    2. Reload the tree view
    3. Expand the nodes under the context node.

    There are a few scenarios where I would like to do this:

    • I have just finished editing an item in the tree. For example, I may have changed the title displayed in the tree.
    • I have just deleted an item from the tree
    • I have just added an item to the tree

    My first inclination was to use the FullPath property to identify my context node and then use GetItemByPath to retrieve that node after reloading the tree. I would then load and expand the context node's subtree. I have been encountering some difficulty with FulPath though. It appears that the FullPath property throws an exception for any node that has children that have not yet been loaded. Is this a bug or by design? Am I going about this the wrong way? Do you have any advice or sample code for this type of thing?

    Thanks
    Rob

  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 24 Jul 2008 Link to this post

    Hello Rob,

    I already wrote you in anothe ticket, but just want to clarify that the GetItemByPath method is not giving an excpetion - it just returns null, because the item you are looking for is still not generated.  Once again - see how the ItemContainerGenerator is used in order to make your scenario working.

    Let us know if you have problems implementing the logic. We will write a KB article soon about how to traverse the RadTreeView.

    Sincerely yours,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Josef Rogovsky
    Josef Rogovsky avatar
    147 posts
    Member since:
    Sep 2012

    Posted 01 Sep 2009 Link to this post

    Is there an update on this?
  4. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 01 Sep 2009 Link to this post

    Hi Josef Rogovsky,

    Yes, there are now two methods that will expand to an item.

    The GetItemByPath(path) method will expand to an item synchronously and it will return this item. The GetItemByPath method should not return null if the item is reachable.

    The ExpandItemByPath(path) will expand to an item asynchronously. This is why it does not return the item.

    Greetings,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Josef Rogovsky
    Josef Rogovsky avatar
    147 posts
    Member since:
    Sep 2012

    Posted 14 Sep 2009 Link to this post

    Hi Miroslav,

    What I'm hoping to see soon is a KB article on how to traverse the tree. I've recently posted a support ticket for basically this request because I need to be able to find and select nodes by value where I have no idea of the path.
  6. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 17 Sep 2009 Link to this post

    Hi Josef,

    Yes, due to the lazy manner in which Silverlight and WPF controls are loaded, it is not trivial to select an item by its value (and not its path).

    Almost certainly this will not be a built-in feature of the TreeView and it has to be done in the underlying ViewModel.

    The problem is that the TreeView has no idea of the existence or value of items in the branches that have not been expanded yet. With the Q3 release the TreeView will be virtualized, which means that only the visible 20-30 item containers will be present - this will improve the performance but it will mean that increasingly containers will not be available. Then, if there are no containers, there is no reasonable way to get the subitems of the root-level items.

    Thank you for the reminder, I will prepare an example with the different cases of getting an item.

    I will reply to your other thread as well with more concrete ideas for your scenario.

    Best wishes,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top