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

how to get the radtreeviewitem?

5 Answers 109 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 23 May 2016, 01:16 AM

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!

5 Answers, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 25 May 2016, 03:06 PM
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.
0
Jonathan
Top achievements
Rank 1
answered on 26 May 2016, 12:19 AM

Thank you Dinko!

I'll try.

0
Jonathan
Top achievements
Rank 1
answered on 26 May 2016, 01:36 AM

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.

0
Dinko
Telerik team
answered on 30 May 2016, 09:30 AM
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.
0
Jonathan
Top achievements
Rank 1
answered on 01 Jun 2016, 05:15 AM
Thank you!
Tags
TreeView
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Jonathan
Top achievements
Rank 1
Share this question
or