This is a migrated thread and some comments may be shown as answers.

[Solved] Tree View's nodes' Color change

3 Answers 199 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nikhil Kashyap
Top achievements
Rank 1
Nikhil Kashyap asked on 31 May 2010, 10:30 AM
Hi,
    Wanted to know, can we change the color of certain nodes in the TreeView ? If yes, then how?

Regards
Nikhil Kashyap

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 May 2010, 12:05 PM
Hello Nikhil Kashyap,

You can style the nodes as any HTML element - by using CSS. You can assign custom css class for the specific nodes by using the HtmlAttributes method:

nodes.Add().Text("Node").HtmlAttributes(new {@class="test"})

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Nikhil Kashyap
Top achievements
Rank 1
answered on 08 Jun 2010, 12:43 PM
Hi,
    Not able to use the syntax which you have given. Attaching the screenshot of my code where im trying to use this. We are using databinding to load the treeview and depending on some condition we want to change the colors of some nodes. Plz let us know the exact syntax in this case. Thanks

Regards
Nikhil
Customer Id: JT359876
0
Georgi Krustev
Telerik team
answered on 08 Jun 2010, 12:56 PM
Hi Nikhil Kashyap,

In this case you need to add required attribute to the dictionary. Here is a code snippet showing how to achieve this:
mappings.For<Category>(binding => binding
        .ItemDataBound((item, category) =>
        {
            item.HtmlAttributes.Add("class", "test");
            item.Text = category.CategoryName;
        })
        .Children(category => category.Products));

Sincerely yours,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeView
Asked by
Nikhil Kashyap
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Nikhil Kashyap
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or