We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get html-attribute from node on selection


I would like to get the html-attribute "id" from the node when it is selected.

My tree-view is as follows :

<ej-tree-view id="SideBarTreeView" node-select="onNodeSelected" node-click="onNodeClicked">
                <e-tree-view-fields datasource="@Model.SideBarTreeViewList" id="id" parent-Id="pid" text="name" has-child="hasChild" expanded="false" html-attribute="nodeAttribute">

Looking at the source code from my page, the "id" is located in the <li> parent element of the selected node.

Thanks for your support.

2 Replies

CI Christopher Issac Sunder K Syncfusion Team March 25, 2019 07:05 AM UTC

Hi Erik, 

Thank you for contacting Syncfusion support. 

We have checked your requirement – “To get the id of selected node”. The Treeview triggers nodeSelect event each time a node is selected and the details of the selected node(including the id) is passed as arguments to this event. So, you can use this event to achieve your requirement. Please check below code snippet, 

<ej-tree-view id="treeview" node-select="onNodeSelected"> 
    <e-tree-view-fields datasource="ViewBag.datasource" id="Id" parent-id="Parent" text="Text"> 
function onNodeSelected(args){ 
    alert("Node of id " + args.id + " has been selected"); 

We have prepared a sample for your reference. Please find it below, 


Let us know if you require any further assistance. 


ER Erik March 25, 2019 08:33 AM UTC

Works fine, thanks Christopher.

Live Chat Icon For mobile
Up arrow icon