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

How to apply HtmlAttributes for nodes in Treeview?

Platform: ASP.NET MVC (Classic) |
Control: TreeView |
Published Date: January 28, 2015 |
Last Revised Date: February 2, 2015 |
Product Version: 12.4.0.24

Description

You can easily map and apply the Html Attribute to TreeView items by using HtmlAttributes property in TreeViewModel class.

Solution

For applying the Html Attribute to the TreeView items, you have to configure some of the following properties in TreeView model.

  1. Map the HtmlAttributes property to the DataSource field.

C:\Users\ApoorvahR\Desktop\Note.png Note: When LoadOnDemand is required, enable “LoadOnDemand” and assign “RequestMapper” value.

The value of HtmlAttributes should be in the following format,

  1. In order to assign the value to the attribute, use “=” character.

Example: “style=background-color: red; font-weight: bold; height: 21px;

  1. To apply a multiple attribute value’s, use comma (“,”) to separate each attribute and its value.

Example: “style=background-color: red; font-weight: bold;, height= 21px, width=100px

Sample Table Data:

Figure 1: Sample Table Data

Refer to the following code example for SQL Data Binding.

CSHTML

C#               

Refer to the following code example for TreeView SQL Data binding with LoadOnDemand.

C#               

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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