- The Book of Dojo
- The Dojo Book, 0.4
- Part 1: "Introduction"
- Part 2: "Out of the Box" Dojo
- Part 3: "The Dojo Programming Model"
- Part 4: "More on Widgets"
- Part 5: "Connecting the pieces"
- Part 6: "Customizing Dojo Builds for Better Performance"
- Part 7: "Utilities"
- Part 8: "Internationalization and Accessiblity"
- Part 9: "Dojo Community"
- Part 10: "Fresh From The Shed" Dojo
- BookWriting
- Glossary
5 Pre-Expanding Content
Submitted by criecke on Sun, 03/25/2007 - 17:56.
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.
- Printer-friendly version
- Login or register to post comments
- Subscribe post
