how to get the radtreeviewitem?

6 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    26 posts
    Member since:
    Jan 2016

    Posted 22 May Link to this post

    Hi, I add a new xmlelement(ele1) throw the datacontext, and I set the radtreeview.selecteditem=ele1. Then it trigger the selectchanged event, it's easy to get the new node's xmlelement object in this event, but I don't know how to get the new node's radtreeviewitem object.

    How to do it ?  Cause I want to call the radtreeviewitem's beginedit() event to let node start edit style automatically. Thanks!

  2. Dinko
    Admin
    Dinko avatar
    202 posts

    Posted 25 May Link to this post

    Hi Jonathan,

    Let me first start with that in the SelectionChanged event the RadTreeViewItem container for the newly added business object is still not generated. In order to force the tree node to be created, you can call the GetItemByPath() method. You can take a look at the Get Item By Path help article in our documentation where this method is further described. Keep in mind in order to use this method you need to know the path of the added node.

    Another approach which you can try is to subscribe to the ItemPrepared event of the RadTreeView. This event is called when a child of the RadTreeView has been prepared and is now ready for use. You can take a look at the Working with ItemPrepared Event for further information.
    private void tree_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
    {
        var item = e.PreparedItem as RadTreeViewItem;
    }

    Hope this information is helpful.

    Regards,
    Dinko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jonathan
    Jonathan avatar
    26 posts
    Member since:
    Jan 2016

    Posted 25 May in reply to Dinko Link to this post

    Thank you Dinko!

    I'll try.

  5. Jonathan
    Jonathan avatar
    26 posts
    Member since:
    Jan 2016

    Posted 25 May in reply to Dinko Link to this post

    Hi, Dinko!

    When I use GetItemByPath method, how to deal with the duplicate node?

    If the TextSearch.TextPath set Name, I can find the first node. How to find others?

    And this method wouldn't work in the SelectionChanged event, when I try to find the childnode of current node.It just return null.

  6. Dinko
    Admin
    Dinko avatar
    202 posts

    Posted 30 May Link to this post

    Hello Jonathan,

    Basically, if there is a duplicate node the GetItemByPath() method will return the first node placed on a current level. The behavior is expected by design. If there is a possibility of duplicate name you can create a property which will be unique for every node and set this property to the TextSearch.Path="UniquePath".

    Regards,
    Dinko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  7. Jonathan
    Jonathan avatar
    26 posts
    Member since:
    Jan 2016

    Posted 01 Jun in reply to Dinko Link to this post

    Thank you!
Back to Top
UI for WPF is Visual Studio 2017 Ready