Login Register

5 Pre-Expanding Content

Let's say you'd like to highlight a particular Tree node, for example a default value. You can do this easily enough with tags around the node title:
<div dojoType="TreeNode"...>
  <div dojoType="TreeNode"...>
    <div dojoType="TreeNode" title="<span style='background-color:yellow' >The most popular choice</span>" />
    ...
  </div>
  <div dojoType="TreeNode"...>
    <div dojoType="TreeNode" title="Another Choice" />
  </div>
</div>
But if this TreeNode is 3 levels down, the user will have to expand both levels above it. A better way is to pre-expand content levels. This requires the attribute "expandLevel", which means "expand all nodes that are n levels below" If n is more than 1, all levels between 1 and n are expanded, since seeing an expanded node requires seeing an expanded node above. For example, if you added expandLevel="2" to the top TreeNode:
<div dojoType="TreeNode" expandLevel="2" ...>
  <div dojoType="TreeNode"...>
  ...
then both The Most Popular Choice and Another Choice will appear. But:
<div dojoType="TreeNode" expandLevel="1" ...>
   <div dojoType="TreeNode" expandLevel="1" ...>
   ...
  </div>
  <div dojoType="TreeNode"...>
</div>
will only expand Most Popular Choice.