Tree
The Tree dijit is an amazing
piece of engineering. Using completely native DHTML, it looks and acts
just like you'd expect a hierarchical tree to look and act, it
supports drag-and-drop operations, and it's flexible enough to bind to
an arbitrary data source. Like any other complex piece of machinery,
there are a few fundamentals to pick up before you get rolling with
it, but they're all fairly intuitive once you've connected the dots
that first time. This is one of the longer sections in the chapter
because the Tree is quite powerful
and offers an extensive set of features. Although we won't elaborate
on a11y, you should also be cognizant that the Tree is quite accessible with the keyboard
via arrow keys, the Enter key, and so on.
Tip
A good understanding of the dojo.data API is especially helpful for
working with the Tree dijit. See
Chapter 9 for more details.
Before reading through any code, it's helpful to be aware of at least a few things:
- Trees and forests
A tree is a hierarchical data structure that contains a single root element. A forest, on the other hand, is a hierarchical structure just like a tree except that it does not have a single root node; instead, it has multiple root nodes. As we'll see, distinguishing between a tree and a forest is a common issue because many data views are conveniently expressed as a tree with a single root node even though the data that backs the view is a forest with an implied root node.
- Nodes
A tree is a hierarchical organization of nodes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access