Login Register

Tree

(writing in progress - very incomplete!  -- Bill)

Introduction

The Dojo 0.4 TreeV3 code is documented as a tutorial by Ilia, and also some basic stuff in the manual, plus the tests. The TreeV3 code has a lot of features, not all of which will be able to transfer to Dijit for the 1.0 release, due to time constraints and also the goal of making Dijit a toolkit of simple easy-to-use widgets, rather than making it all things for all people.   The other big change is that the Dijit tree will be based off of dojo.data, which affects creating trees both in markup and of course, when lazy-loading data from the server.

Goals

Creation from a store:

<script>
    var myStore = new dojo.data.JsonItemStore(...);
</script>
<div dojoType=dijit.Tree store=myStore></div>

Inline

Obviously one way to inline tree data into a web page is to write it in JSON and hook it up to a JsonItemStore (see the example above and replace the ... with JSON text. We could also support data inlined into HTML, like this:
<div dojoType=dijit.Tree>
  <ul>
     <li>Item 1
     <li>Item 2
          <ul>
              <li>Item 2.1
              <li>Item 2.2
          </ul>
     <li>Item 3
   </ul>
</div>
I'd like to hopefully get someone else to implement this, as a specialized data store though, and not worry about it as part of the tree spec.   Note that the example is simplified because each node has attributes such as id, value, etc. TODO:
  •  interface for events on nodes (what are the events w.r.t A11Y?   not click, but select?  and what about double-click or right-click?)
  • saving tree state (opened closed nodes) and restoring them

Non-goals

  • DND - will do DnD eventually, but not for version 1.0.
  • Selection?  Selecting nodes is useful (and necessary) for DnD but probably not too important otherwise
  • Expand to node on select: this feature requires the tree to automatically open when a certain node is selected programatically, which in turn means that you have to be able to select a node programatically (which maybe the tree hasn't even read from the dojo.data source yet).   I'm not sure how all of that can work against dojo.data.
  • Editing a node
  • Adding/Deleting nodes
  • context menu (but should be easy to implement via interface to tree events (see above)
  • classPrefix
  • lazy creation: see the dojo.data section instead
  • highly customizable controller

Node Parameters

Each node of the tree will have these parameters:
  • editable (Boolean)
  • value/id
  • type (this has to map somehow to specify the icon)
  • label (HTML)
  • children
Actually I guess that we will just have a dojo.data item for each node in the tree, which users can access to get any data they want.

A11Y

A11Y is supported in the old tree and will be in the new tree, but not sure of the details.   Becky, please fill in this section after we flesh out what features are supported in general.