I've been going through the docs, trying different things and skimming
though this discussion group, but cannot find an answer to the
following question: how can I style individual nodes?
For example: I want to set the forground/background color, the icon
etc. on a node by node basis. Is this possible?
Also: Can I disable Icons on the tree altogether?
Tnx,
K.
--
You received this message because you are subscribed to the Google Groups "jsTree" group.
To post to this group, send email to jst...@googlegroups.com.
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jstree?hl=en.
Tnx for the response.
So, what do I mean... :-)
My tree is database record driven and is very dynamic in nature, so
each view of the tree can can have a completely different structure.
All nodes do have an ID though. Serverside I generate the initial JSON
data for the nodes and there I have the info for the styling per node.
I'd like to include the styling info directly in the JSON string and
not generate a custom stylesheet for each time the tree is viewed.
I tried adding style info through the attributes of the node, but that
styling info goes into the style attribute of the corresponding LI
element, whereas I'd like it to go into the A element, as I need to be
able to set the color style attribute and that doesn't cascade down
from the LI element to it's child A element containing the node's
text. Am I missing something?
You also say: "Or you can set the appropriate value in the node
definition to turn them off."
What is the "appropriate value" for turning the icon off in the node
info?
Tnx,
K.
> > jstree+un...@googlegroups.com<jstree%2Bunsu...@googlegroups.com>
Hi John,
Tnx for the response.
So, what do I mean... :-)
My tree is database record driven and is very dynamic in nature, so
each view of the tree can can have a completely different structure.
All nodes do have an ID though. Serverside I generate the initial JSON
data for the nodes and there I have the info for the styling per node.
I'd like to include the styling info directly in the JSON string and
not generate a custom stylesheet for each time the tree is viewed.
I tried adding style info through the attributes of the node, but that
styling info goes into the style attribute of the corresponding LI
element, whereas I'd like it to go into the A element, as I need to be
able to set the color style attribute and that doesn't cascade down
from the LI element to it's child A element containing the node's
text. Am I missing something?
If you need to specify some attributes for the <a> node in the output, or want to set a custom icon instead of a string, pass an object for the data section. Like so:
{
attributes: { id : "node_identificator", some-other-attribute : "attribute_value" },
data: { title : "Node title", icon : "path_to/icon.pic", attributes : {"key" : "value" } },
// Properties below are only used for NON-leaf nodes
state: "closed", // or "open"
children: [ /* an array of child nodes objects */ ]
}
The key/value can be 'style'. Or any other html attribute, for that matter, like 'class' or 'target'.
You also say: "Or you can set the appropriate value in the node
definition to turn them off."What is the "appropriate value" for turning the icon off in the node
info?