dojox/grid/LazyTreeGridStoreModel (version 1.10)

dijit/tree/ForestStoreModel

Usage

var foo = new LazyTreeGridStoreModel(args);
dojox/grid/LazyTreeGridStoreModel
Parameter Type Description
args Object

Property Summary

  • childrenAttrsOne or more attribute names (attributes in the dojo.data item) that specify that item's children
  • deferItemLoadingUntilExpandSetting this to true will cause the TreeStoreModel to defer calling loadItem on nodes until they are expanded.
  • labelAttrIf specified, get label for tree node from this attribute, rather than by calling store.getLabel()
  • newItemIdAttrName of attribute in the Object passed to newItem() that specifies the id.
  • querySpecifies the set of children of the root item.
  • rootPointer to the root item (read only, not a parameter)
  • rootIdID of fabricated root item
  • rootLabelLabel of fabricated root item
  • serverStore
  • storeUnderlying store

Method Summary

Event Summary

  • onAddToRoot(item) Called when item added to root of tree; user must override this method to modify the item so that it matches the query for top level items
  • 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.
  • onDelete(item) Callback when an item has been deleted.
  • onDeleteItem(item)
  • onLeaveRoot(item) Called when item removed from root of tree; user must override this method to modify the item so it doesn't match the query for top level items
  • onNewItem(item,parentInfo)
  • onNewRootItem(args) User can override this method to modify a new element that's being added to the root of the tree, for example to add a flag like root=true
  • onSetItem(item,attribute,oldValue,newValue) Updates the tree view according to changes to an item in the data store.

Properties

childrenAttrs

One or more attribute names (attributes in the dojo.data item) that specify that item's children

deferItemLoadingUntilExpand

Setting this to true will cause the TreeStoreModel to defer calling loadItem on nodes until they are expanded. This allows for lazying loading where only one loadItem (and generally one network call, consequently) per expansion (rather than one for each child). This relies on partial loading of the children items; each children item of a fully loaded item should contain the label and info about having children.

labelAttr

If specified, get label for tree node from this attribute, rather than by calling store.getLabel()

newItemIdAttr

Name of attribute in the Object passed to newItem() that specifies the id.

If newItemIdAttr is set then it's used when newItem() is called to see if an item with the same id already exists, and if so just links to the old item (so that the old item ends up with two parents).

Setting this to null or "" will make every drop create a new item.

query

Specifies the set of children of the root item.

root

Pointer to the root item (read only, not a parameter)

rootId

ID of fabricated root item

rootLabel

Label of fabricated root item

serverStore
store

Underlying store

Methods

_isChildrenLoaded(parentItem)

Check if all children of the given item have been loaded

Parameter Type Description
parentItem undefined
Returns:undefined
_requeryTop()
destroy()
fetchItemByIdentity(keywordArgs)
Parameter Type Description
keywordArgs object
getChildren(parentItem,onComplete,onError,queryObj)
Parameter Type Description
parentItem dojo.data.Item
onComplete function(items, size)
onError function
queryObj object
getIdentity(item)
Parameter Type Description
item item
Returns:undefined
getLabel(item)
Parameter Type Description
item item
Returns:undefined
getRoot(onItem,onError)

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

Parameter Type Description
onItem undefined
onError undefined
isItem(something)
Parameter Type Description
something anything
Returns:boolean
mayHaveChildren(item)
Parameter Type Description
item dojo.data.Item
Returns:undefined
newItem(args,parent,insertIndex)

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
Returns:undefined
pasteItem(childItem,oldParentItem,newParentItem,bCopy,insertIndex)

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

Events

onAddToRoot(item)

Called when item added to root of tree; user must override this method to modify the item so that it matches the query for top level items

Parameter Type Description
item item

Examples

Example 1

store.setValue(item, "root", true);
onChange(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

Examples

Example 1

store.setValue(item, "root", true);
onChildrenChange(parent,newChildrenList)

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

Parameter Type Description
parent dojo/data/Item
newChildrenList dojo/data/Item[]

Examples

Example 1

store.setValue(item, "root", true);
onDelete(item)

Callback when an item has been deleted.

Note that there will also be an onChildrenChange() callback for the parent of this item.

Parameter Type Description
item dojo/data/Item

Examples

Example 1

store.setValue(item, "root", true);
onDeleteItem(item)
Parameter Type Description
item undefined

Examples

Example 1

store.setValue(item, "root", true);
onLeaveRoot(item)

Called when item removed from root of tree; user must override this method to modify the item so it doesn't match the query for top level items

Parameter Type Description
item item

Examples

Example 1

store.unsetAttribute(item, "root");
onNewItem(item,parentInfo)
Parameter Type Description
item undefined
parentInfo undefined

Examples

Example 1

store.unsetAttribute(item, "root");
onNewRootItem(args)

User can override this method to modify a new element that's being added to the root of the tree, for example to add a flag like root=true

Parameter Type Description
args dijit/tree/dndSource.__Item

Examples

Example 1

store.unsetAttribute(item, "root");
onSetItem(item,attribute,oldValue,newValue)

Updates the tree view according to changes to an item in the data store. Developers should override this method to be more efficient based on their app/data.

Handles updates to an item's children by calling onChildrenChange(), and other updates to an item by calling onChange().

Also, any change to any item re-executes the query for the tree's top-level items, since this modified item may have started/stopped matching the query for top level items.

If possible, developers should override this function to only call _requeryTop() when the change to the item has caused it to stop/start being a top level item in the tree.

Parameter Type Description
item item
attribute attribute-name-string
oldValue Object | Array
newValue Object | Array

Examples

Example 1

store.unsetAttribute(item, "root");
Error in the documentation? Can’t find what you are looking for? Let us know!