How to get node Id when node is selected?

2 posts, 0 answers
  1. Havard
    Havard avatar
    2 posts
    Member since:
    Dec 2010

    Posted 18 Aug 2014 Link to this post

    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
  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 20 Aug 2014 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top