Version 5, changed by owen 12/09/2006. Show version history
.. title:: dojo.widget.TreeController? -- The Dojo Manual
Name
===============================================================================
dojo.widget.TreeController? -Tree Widget Controller
Summary and Overview
===============================================================================
This class, together with Tree, TreeSelector?, and
TreeNode, provide a tree widget with nodes that can be
dynamically added, modified, and deleted.
This applies to TreeController? as of 2006/02/23.
Usage
===============================================================================
See Tree.
API Reference
===============================================================================
Inherits From
--------------------------------------
``dojo.widget.HtmlWidget``
Properties
---------------------------------------
``RPCUrl``:
String URL of a page that generates information for
dynamic loading of tree nodes. ``action=xxx`` and
node-specific information is always added in the request's query
string.
``DNDMode``:
Default ``off``. Controls the mode of drag-and-drop. Other
possible modes are ``onto`` and ``between``. TODO: document
these.
``eventNames``:
Object with properties select, deselect, collapse, expand,
dblselect, move, remove. TODO: document these.
``dragSources``:
TBD
``dropTargets``:
TBD
``errorHandler``:
Function to be called in case of errors in the internal I/O.
Used exactly as an error handler for dojo.io.bind.
Initialization Protocol
-----------------------
``initialize``:
Sets up this controller's event names as widgetId+"/"+eventName.
Methods
--------
``subscribeTree(tree)``:
Subscribes this controller to the topics specified by the tree's
eventNames: nodeCreate, treeClick, iconClick, and titleClick.
They fire the controllers matching onNodeCreate, onTreeClick, onIconClick,
and onTitleClick events. Normally called by the tree during its creation.
``loadRemote(node, sync, callback, callObj)``:
Issues a request for loading the node's children. Requests the
page specified by the RPCUrl with action=getChildren and
data=xxx, where the value is the JSON representation of an
object with two properties: "node" and "tree". The value of the
"node" is the result of node.getInfo(), and the value of the
"tree" is the result of tree.getInfo().
Passes the received JSON object to loadProcessResponse.
Other parameters TBD.
``loadProcessResponse(type, node, result, callback, callObj)``:
Type is supplied by ``dojo.io.bind`` as the response type. Node
is the tree node. Result is the object created from the response
JSON data.
The JSON data is an array containing objects. This supplies each
object as the information argument to dojo.widget.createWidget,
and specifies the node's ``widgetType`` as the widget type for all
new children. This adds the new children to the node and mark's
the node as loaded.
Finally if a callback is supplied, this calls it so that the callObj is
``this``, passing the node and new children as arguments. The
callObj defaults to being the controller.
``expand(node, callObj, callFunc, sync)``:
Normally called from onTreeclick.
If the node's load state is "unchecked", calls loadRemote,
with a callback function that expands the parent node when loading
is done.
Otherwise call's the node's expand method and publishes on the
eventNames.expand topic.
In all cases if there is a callFunc, calls it with callObj as
"this" and the node as the one argument.
``collapse(node)``:
If the node is expanded, calls node.collapse, then publishes on the
eventNames.collapse topic.
``select(node)``:
Called from onTitleClick. Calls the node's ``markSelected``
method, records it as the tree selector's selectedNode, and
publishes on the controller's eventNames.select topic.
``deselect(node)``:
Call's the node's unMarkSelected method, sets the selector's
selectedNode to null, and publishes on the eventNames.deselect
topic.
Events
--------
These events are set up by the subscribeTree method.
onTreeClick:
This expands or collapses the appropriate node. If the node has
never before been expanded and has no children, this calls
``loadRemote``.
onIconClick:
Calls onTitleClick.
onTitleClick:
If the clicked node is the tree selector's seelectedNode,
publishes on the controller's dblselect topic. If there is a
previously selected node, calls this controller's deselect method
on that node. Then calls this controller's ``select`` method on
the clicked node.
Topics Published
-----------------
TBD
About
===============================================================================
:Author: Cris Perdue
:Version: 0.2.2
:Copyright: Dojo Foundation, 2006
:Date: 2006/02/12
.. vim:ts=4:et:tw=80:shiftwidth=4: