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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get html-attribute from node on selection

Thread ID:

Created:

Updated:

Platform:

Replies:

143493 Mar 22,2019 02:36 PM UTC Mar 25,2019 08:33 AM UTC ASP.NET Core 2
loading
Tags: Treeview
Erik
Asked On March 22, 2019 02:36 PM UTC

Hi,

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">
                </e-tree-view-fields>
            </ej-tree-view>


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.







Christopher Issac Sunder K [Syncfusion]
Replied On 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"> 
    </e-tree-view-fields> 
</ej-tree-view> 
 
<script> 
function onNodeSelected(args){ 
    alert("Node of id " + args.id + " has been selected"); 
} 
</script> 

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

Sample: 

Let us know if you require any further assistance. 

Thanks,
Christo 


Erik
Replied On March 25, 2019 08:33 AM UTC

Works fine, thanks Christopher.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;