dijit/tree/model (version 1.10)

Summary

Contract for any data provider object for the tree.

Tree passes in values to the constructor to specify the callbacks. "item" is typically a dojo/data/Item but it's just a black box so it could be anything.

This (like dojo/data/api/Read) is just documentation, and not meant to be used.

Method Summary

  • destroy() Destroys this object, releasing connections to the store
  • getChildren(parentItem,onComplete) Calls onComplete() with array of child items of given parent item, all loaded.
  • getIdentity(item) Returns identity for an item
  • getLabel(item) Get the label for an item
  • getRoot(onItem) Calls onItem with the root item for the tree, possibly a fabricated item.
  • isItem(something) Returns true if something is an item and came from this model instance.
  • mayHaveChildren(item) Tells if an item has or may have children.
  • newItem(args,parent,insertIndex,before) Creates a new item.
  • pasteItem(childItem,oldParentItem,newParentItem,bCopy,insertIndex,before) Move or copy an item from one parent item to another.

Event Summary

  • onChange(item) Callback whenever an item has changed, so that Tree can update the label, icon, etc.
  • onChildrenChange(parent,newChildrenList) Callback to do notifications about new, updated, or deleted items.

Methods

destroy()
Defined by dijit/tree/model

Destroys this object, releasing connections to the store

getChildren(parentItem,onComplete)
Defined by dijit/tree/model

Calls onComplete() with array of child items of given parent item, all loaded. Throws exception on error.

Parameter Type Description
parentItem dojo/data/Item
onComplete undefined
getIdentity(item)
Defined by dijit/tree/model

Returns identity for an item

Parameter Type Description
item undefined
getLabel(item)
Defined by dijit/tree/model

Get the label for an item

Parameter Type Description
item undefined
getRoot(onItem)
Defined by dijit/tree/model

Calls onItem with the root item for the tree, possibly a fabricated item. Throws exception on error.

Parameter Type Description
onItem undefined
isItem(something)
Defined by dijit/tree/model

Returns true if something is an item and came from this model instance. Returns false if something is a literal, an item from another model instance, or is any object other than an item.

Parameter Type Description
something undefined
mayHaveChildren(item)
Defined by dijit/tree/model

Tells if an item has or may have children. Implementing logic here avoids showing +/- expando icon for nodes that we know don't have children. (For efficiency reasons we may not want to check if an element actually has children until user clicks the expando node)

Parameter Type Description
item dojo/data/Item
newItem(args,parent,insertIndex,before)
Defined by dijit/tree/model

Creates a new item. See dojo/data/api/Write for details on args.

Parameter Type Description
args dijit/tree/dndSource.__Item
parent Item
insertIndex int
Optional

Allows to insert the new item as the n'th child of parent.

before Item
Optional

Insert the new item as the previous sibling of this item. before must be a child of parent.

pasteItem(childItem,oldParentItem,newParentItem,bCopy,insertIndex,before)
Defined by dijit/tree/model

Move or copy an item from one parent item to another. Used in drag & drop. If oldParentItem is specified and bCopy is false, childItem is removed from oldParentItem. If newParentItem is specified, childItem is attached to newParentItem.

Parameter Type Description
childItem Item
oldParentItem Item
newParentItem Item
bCopy Boolean
insertIndex int
Optional

Allows to insert the new item as the n'th child of parent.

before Item
Optional

Insert the new item as the previous sibling of this item. before must be a child of parent.

Events

onChange(item)
Defined by: dijit/tree/model

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
onChildrenChange(parent,newChildrenList)
Defined by: dijit/tree/model

Callback to do notifications about new, updated, or deleted items.

Parameter Type Description
parent dojo/data/Item
newChildrenList dojo/data/Item[]
Error in the documentation? Can’t find what you are looking for? Let us know!