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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

C# MVC EJ2 Treeview, How to add custom data-attribute to nodes?

Thread ID:





151151 Feb 1,2020 11:58 AM UTC Feb 3,2020 12:57 PM UTC ASP.NET MVC - EJ 2 1
Tags: Treeview
Asked On February 1, 2020 11:58 AM UTC

In standard html you have the ability to add additional data attributes to elements data-uid="1",

When i generate my treeview node items from code behind how can i add a custom data attribute to the specific node?

in the EJ1 version they have a option called LinkAttributes, what is the EJ2 equivalent of that option?

the reason i want these data attributes, is because i am attaching a context menu to the treeview node clicks and depending on the value of the data attribute decides what
context menu options should be displayed.

 result.Add(new TreeViewModel
                        Id = (int)parentId,
                        Name = "Areas",
                        HasChild = db.Area.Any(a => a.SiteId == parentId),
                        Expanded = false,
                        Selected = false,
                        ImageUrl = "../Images/Icons/location-active.png",
                        HtmlAttributes = "?????????"

Shameer Ali Baig Sulaiman Ali Baig [Syncfusion]
Replied On February 3, 2020 12:57 PM UTC

Hi Patrick, 
Greetings from Syncfusion support. 
We have checked your reported query to how to add html attributes in TreeView node.  It is possible to add it in the TreeView component. Refer the below link for your requirement. 
In this sample, we have added Html attributes for TreeView nodes. 
Please let us know, if you need any further assistance. 
Shameer Ali Baig S. 


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

Live Chat Icon For mobile
Live Chat Icon