Login Register

Hierachical data and dojo.data

Currently, you can add hierachical data to a dojo.data.Store. However there is currently no concept of data hierarchy in the stores after creation. I'll give you a concrete example using the Tree widget:

I bind a ItemFileWriteStore to a tree.
I hack the tree.DataController to connect to the onNew() function of the store. I receive the event notifications when the store has an item added. I need to insert the newly added item into the tree - however, I need to know 'where' the new item is in the store (i.e. what is parent and children are).

dojo.declare(
"dijit._tree.DataController",
dijit._tree.Controller,
{
// summary Controller for tree that hooks up to dojo.data
onAfterTreeCreate: function(message){
// when a tree is created, we query against the store to get the top level nodes in the tree
var tree = message.tree;

if( tree.store.getFeatures()['dojo.data.api.Write'] == true )
{
dojo.connect( this.store, "onNew", this, function( newItem ) { this._addNode( tree, newItem); } );
}

In the _addNode function of the DataController, I have the new item and access to the store. I can find out if the new item is a top level item, but cannot see how I am meant to find 'relationship' info for the new item.

Is it that 'relationship' data is deliberately not in the store, i.e is the 'shape' of the data deliberately none of the store's business?
I know from Bill's responses to my previous posts about the Tree that the Tree->Store interactions have not been coded yet, I just want to know if I code my own TreeController and Store, should I include parent and child semantics or is this a definite no-no?