Set TreeNode font, color and background by using css

There is any way to control the style of tree node by change his css class ?
I want to change the class and not the style attribute.


You can’t change the style name, but there is a method setItemStyle … titemstyle
but you need to write a style string there.
So there is the one more way: change all you need in tag…

When I am changing the style tag and set background-color to TreeNode the background color taking the control all the time, even when the TreeNode is Selected by the user (The CSS class “.selectedTreeRow” is hidden)

I fixed this problem, but not by using DHTMLXTree API and it’s a little bit shame.
It will be great if I can control the CSS class by myself.

Thanks for the quick answer,

Could you explane the style behaviour (i.e. selected node) - we wi;; try to sugest you something concerning your case.

In my Web App I need to mark some of the TreeNodes (when some tree node is over specific threshold that calculated in the server side).

So, What I am doing is changing the background-color and the text color of those tree nodes.

But, when the user select a specific tree node I want that this node will be marked as “Selected”, this happen automatically, the tree node CSS class changed to “.selectedTreeRow”, but, the the background color doesn’t change because I override the style tag.

So, the best solution is if I got the option to control on the Tree Node CSS class and changed him as much as I want.
In this way, I get all the good things that came with xhtmlxTree and I can add my functionality without conflicts.

I hope this explained my situation


Unfortunatelly setItemStyle is the only way you can use in your case.
You can suggest such functionality you need here: