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

How to get node Id when node is selected?

1 Answer 578 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Havard
Top achievements
Rank 1
Havard asked on 18 Aug 2014, 09:06 AM
Hi,

I am new to Telerik components, and this is probably a question which is easy to answer ;

I have a treeview control on my page. All nodes in the tree have unique Ids. The treeview is not linked to a datasource; the nodes are static.

I need to catch a node selected event, and get the node Id. This is to be forwarded to other functions to enable functionality. It seems to me that I need to have a ActionLink on the nodes for the onSelect event to trigger. (?) I do not want to use the treeview for ActionLink style navigation, how can I catch onSelect events and simply get the Id of the node?

Thanks,
Havard

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 20 Aug 2014, 05:03 AM
Hello Havard,

If I understand correctly, you are rendering the TreeView nodes as list items with an ID attribute. If that is the case, you can get the id in the select event handler by accessing the e.node parameter. See the following example from the documentation. It shows how to access the id of a datasource-bound treeview, but the same approach (using the e.node parameter) can be used for any TreeView rendering.

Regards,
Alex Gyoshev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeView
Asked by
Havard
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or