How to changing colour of individual tree leafs on event?

1,028 views
Skip to first unread message

Serg B

unread,
Feb 21, 2011, 9:30:21 AM2/21/11
to Discuss jquery.dynatree.js
Hi All

Is there a way to change the colour of an individual tree leaf on
custom event?

For example: I have a tree with three levels, level three is a leaf
with two parents above ('folders'). The leaf is more or less a 'to-do'
note. What I would like, is for the leaf to change font colour from
default black to red or green or whatever, depending on the status of
the to-do note or some event that I trigger.

I've been tweaking it with no luck, any help would be greatly
appreciated.



Cheers
Serg

sh0gun

unread,
Feb 21, 2011, 1:07:13 PM2/21/11
to dyna...@googlegroups.com
Sure, look up the argument: "addClass" to add a specific class.

To give you an idea:

My CSS:

label.compressed { color: #0000ff; }
label.empty { color: #707070; }
label.denied { color: #cc0000; }

I return DynaTree is JSON format with the addClass where applicable:

..., "addClass":"compressed", ...

..., "addClass":"denied", ...

etc.


Hope this helps.
Shogun

2011/2/21 Serg B <serge...@gmail.com>:

> --
> You received this message because you are subscribed to the Google
> Groups "Discuss jquery.dynatree.js" group.
> To post to this group, send email to dyna...@googlegroups.com
> To unsubscribe from this group, send email to
> dynatree+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/dynatree?hl=en

Serg B

unread,
Feb 22, 2011, 9:26:43 AM2/22/11
to Discuss jquery.dynatree.js
UPDATE #2:

Problem solved. Was using 'a' for leafs, added the noLink flag. All
good. The 'addClass' put me on the right path. Thanks!

On Feb 22, 5:07 am, sh0gun <prana...@gmail.com> wrote:
> Sure, look up the argument: "addClass" to add a specific class.
>
> To give you an idea:
>
> My CSS:
>
> label.compressed { color: #0000ff; }
> label.empty { color: #707070; }
> label.denied { color: #cc0000; }
>
> I return DynaTree is JSON format with the addClass where applicable:
>
> ..., "addClass":"compressed", ...
>
> ..., "addClass":"denied", ...
>
> etc.
>
> Hope this helps.
> Shogun
>
> 2011/2/21 Serg B <sergesli...@gmail.com>:

Sergicles

unread,
Feb 22, 2011, 7:48:15 AM2/22/11
to Discuss jquery.dynatree.js
Thanks Shogun

I gave it a go, no luck.

I am trying to do this in the 'onActive' event for starters to test
it.

E.g.

$("#tree").dynatree(
{
onActivate: function(node)
{
node.title.addClass = 'viewed'; // viewed is a CSS class defined
elsewhere.
...

Obviously I am missing something, any suggestions as to what?


On Feb 22, 5:07 am, sh0gun <prana...@gmail.com> wrote:
> Sure, look up the argument: "addClass" to add a specific class.
>
> To give you an idea:
>
> My CSS:
>
> label.compressed { color: #0000ff; }
> label.empty { color: #707070; }
> label.denied { color: #cc0000; }
>
> I return DynaTree is JSON format with the addClass where applicable:
>
> ..., "addClass":"compressed", ...
>
> ..., "addClass":"denied", ...
>
> etc.
>
> Hope this helps.
> Shogun
>
> 2011/2/21 Serg B <sergesli...@gmail.com>:

babr....@gmail.com

unread,
Dec 20, 2014, 1:31:18 AM12/20/14
to dyna...@googlegroups.com, pran...@gmail.com
Thank you very much brother you solved my problem actually i didn't get any help from other resources but really really appreciating.
Reply all
Reply to author
Forward
0 new messages