dijit/tree/Model that owns the data shown in a dijit/Tree. What it does is map from a
dojo/store to the tree model.
Each element in the store must have the following:
• id – A unique id that is unique against all other elements in the store.
• name – The label shown in the tree. The name of this property is the default but can be
changed with the "labelAttr" property.
• type – The type of the item in the tree. The name of this property is the default but can be
changed with the "typeAttr" property.
• parent – The id of the parent in the tree
The store object that holds the data should have a getChildren() method added to it. This
should return the children of the passed in item. This is needed to obtain the children for the tree.
By default, the tree seems to show an expand/contract for every entity in it. We can be a bit better
about this by implementing the mayHaveChildren method on the ObjectStoreModel to
return true or false. We should return false only if we know that the entry will never have children.
An example of creating an ObjectStoreModel might be:
var store = new Memory({
data: [
{ id: 0, name:'Root', type:'Root'}
]
}); // End of store
store.getChildren = function(item){
// Add a getChildren() method to store for the data model where
// children objects point to their parent (aka relational model)
return this.query({parent: this.getIdentity(item)});
};
store = new Observable(store);
var model = new ObjectStoreModel({
store: store,
query: {id: 0},
mayHaveChildren: function(item) {
if (item.type == "Metric") {
return false;
}
return true;
}
});
See also:
• dijit/Tree
• Dojo Docs – dijit/tree/ObjectStoreModel – 1.9
• Connecting a store to a tree – 1.9
• Object Stores and Data Stores
dijit/tree/TreeStoreModel – Do Not Use
We list this class here only for reference it has been deprecated by new dojo/store model and
architecture. Uses the old dojo/data story. There is no obvious known reason to continue to use
this item.
Page 192
Kommentare zu diesen Handbüchern