Welcome Guest Search | Active Topics | Sign In | Register

Dynamically set treenode color with on-demand loading Options
ww3467
Posted: Wednesday, June 8, 2011 1:00:20 PM
Rank: Member
Groups: Member

Joined: 10/1/2010
Posts: 10
I have an existing treeview which I am changing to load on-demand. The colors of the nodes are set dynamically by converting part of the item id to a color. I am currently doing this by setting Node.NormalStyle.ForeColor to the generated color. With the on-demand loading, this works for the top-level items, but not for anything loaded on demand below those.

I have used LookID in other on-demand trees to set the color, but that's not really feasible in this case since I don't know in advance what the colors will be. How can I accomplish this with the on-demand loading?
eo_support
Posted: Wednesday, June 8, 2011 1:03:20 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Style properties such as NormalStyle/HoverStyle are not transferred to the client during load on demand. So that won't work. You can use raw HTML in your node text to do that though. So for example, instead of using "hello" as node text, you can use "<span style='color:blue'>hello</span>" as node text.

Thanks
ww3467
Posted: Wednesday, June 8, 2011 2:12:17 PM
Rank: Member
Groups: Member

Joined: 10/1/2010
Posts: 10
That worked - thanks!
ww3467
Posted: Monday, June 13, 2011 12:02:41 PM
Rank: Member
Groups: Member

Joined: 10/1/2010
Posts: 10
While this solution works for displaying the correct color, it is causing other problems because I was using the node text in other places to pass/display the name of the item. I could probably store the name without the HTML in the node value, but I'll have to make a lot of changes. Is there any other way around this?
eo_support
Posted: Monday, June 13, 2011 12:18:10 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

No. That's the only way to do it.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.