Implements dijit/tree/model connecting dijit/Tree to a dojo/store/api/Store that implements getChildren().
If getChildren() returns an array with an observe() method, then it will be leveraged to reflect store updates to the tree. So, this class will work best when:
1. the store implements dojo/store/Observable 2. getChildren() is implemented as a query to the server (i.e. it calls store.query())
Drag and Drop: To support drag and drop, besides implementing getChildren() and dojo/store/Observable, the store must support the parent option to put(). And in order to have child elements ordered according to how the user dropped them, put() must support the before option.
Parameter | Type | Description |
---|---|---|
args | Object |
See the dijit/tree/ObjectStoreModel reference documentation for more information.
Specifies how to interpret the labelAttr in the data store items. Can be "html" or "text".
Specifies datastore query to return the root item for the tree. Must only return a single item. Alternately can just pass in pointer to root item.
Pointer to the root item from the dojo/store/api/Store (read only, not a parameter)
Destroy this class, releasing any resources registered via own().
Parameter | Type | Description |
---|---|---|
preserveDom | Boolean |
Calls onComplete() with array of child items of given parent item.
Parameter | Type | Description |
---|---|---|
parentItem | Object | Item from the dojo/store |
onComplete | function(items) | |
onError | function |
Get the label for an item
Parameter | Type | Description |
---|---|---|
item | dojo/data/Item |
Calls onItem with the root item for the tree, possibly a fabricated item. Calls onError on error.
Parameter | Type | Description |
---|---|---|
onItem | undefined | |
onError | undefined |
Parameter | Type | Description |
---|---|---|
something | undefined |
Tells if an item has or might have children. Implementing logic here avoids showing +/- expando icon for nodes that we know won't have children. (For efficiency reasons we may not want to check if an element actually has children until user clicks the expando node).
Application code should override this method based on the data, for example
it could be return item.leaf == true;
.
Note that mayHaveChildren() must return true for an item if it could possibly have children in the future, due to drag-an-drop or some other data store update. Also note that it may return true if it's just too expensive to check during tree creation whether or not the item has children.
Parameter | Type | Description |
---|---|---|
item | Object | Item from the dojo/store |
Creates a new item. See dojo/data/api/Write
for details on args.
Used in drag & drop when item from external source dropped onto tree.
Parameter | Type | Description |
---|---|---|
args | dijit/tree/dndSource.__Item | |
parent | Item | |
insertIndex | int |
Optional
|
before | Item |
Track specified handles and remove/destroy them when this instance is destroyed, unless they were already removed/destroyed manually.
The array of specified handles, so you can do for example:
var handle = this.own(on(...))[0];
Move or copy an item from one parent item to another. Used in drag & drop.
Parameter | Type | Description |
---|---|---|
childItem | Item | |
oldParentItem | Item | |
newParentItem | Item | |
bCopy | Boolean | |
insertIndex | int |
Optional
|
before | Item |
Callback whenever an item has changed, so that Tree can update the label, icon, etc. Note that changes to an item's children or parent(s) will trigger an onChildrenChange() so you can ignore those changes here.
Parameter | Type | Description |
---|---|---|
item | dojo/data/Item |
Callback to do notifications about new, updated, or deleted items.
Parameter | Type | Description |
---|---|---|
parent | dojo/data/Item | |
newChildrenList | Object[] | Items from the store |
Callback when an item has been deleted. Actually we have no way of knowing this with the new dojo.store API, so this method is never called (but it's left here since Tree connects to it).
Parameter | Type | Description |
---|---|---|
item | dojo/data/Item |