HI i want to load the the data to the store only when the expando is clicked, for this i am tryin to modify a model, the TreeForest model that is
mayHaveChildren: function(/*dojo.data.Item*/ item){
// summary
// 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)
//changes by Rajat this function will now give expando for each item of type root
//console.log(item);
if(item.type == "root"){
//console.log("returning true");
return true;
}
else
return item === this.root || this.inherited(arguments);
},
getChildren: function(/*dojo.data.Item*/ parentItem, /*function(items)*/ callback, /*function*/ onError){
// summary
// Calls onComplete() with array of child items of given parent item, all loaded.
console.log("SomeBody clicked the Exapndo !!!");
console.log(this.store);
if(parentItem === this.root){
if(this.root.children){
// already loaded, just return
callback(this.root.children);
}else{
//add to store new values here //
**** store.newItem({name: "node3", type: xyz}, parentItem);***
//but this is not working ????? help guys
this.store.fetch({
query: this.query,
onComplete: dojo.hitch(this, function(items){
this.root.children = items;
callback(items);
}),
onError: onError
});
}
}else{
this.inherited(arguments);
}
}
// summary
// 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)
//changes by Rajat this function will now give expando for each item of type root
//console.log(item);
if(item.type == "root"){
//console.log("returning true");
return true;
}
else
return item === this.root || this.inherited(arguments);
},
getChildren: function(/*dojo.data.Item*/ parentItem, /*function(items)*/ callback, /*function*/ onError){
// summary
// Calls onComplete() with array of child items of given parent item, all loaded.
console.log("SomeBody clicked the Exapndo !!!");
console.log(this.store);
if(parentItem === this.root){
if(this.root.children){
// already loaded, just return
callback(this.root.children);
}else{
//add to store new values here //
**** store.newItem({name: "node3", type: xyz}, parentItem);***
//but this is not working ????? help guys
this.store.fetch({
query: this.query,
onComplete: dojo.hitch(this, function(items){
this.root.children = items;
callback(items);
}),
onError: onError
});
}
}else{
this.inherited(arguments);
}
}
as you see i want to insret a new item to store and then update the children now my idea is to get these items from the server using an XHR call, can this be done ???
Please help
Dino

oldChildren has no properties
this is the error i get from firebug
(no name)([Object name=[1] type=[1] _RI=true _S=Object _0=0, Object name=[1] type=[1] _RI=true _S=Object _0=1])dojo.js (line 1337)
(no name)([Object name=[1] type=[1] _RI=true _S=Object _0=0, Object name=[1] type=[1] _RI=true _S=Object _0=1], Object query=Object store=Object)dojo.js (line 102)
(no name)(Object query=Object store=Object, [Object name=[1] type=[1] _RI=true _S=Object _0=0, Object name=[1] type=[1] _RI=true _S=Object _0=1, Object _S=Object _0=2 name=[1] _RI=true nodeId=[1]])dojo.js (line 277)
(no name)(Object query=Object store=Object, function(), function())dojo.js (line 295)
(no name)(Object query=Object store=Object)dojo.js (line 105)
(no name)()dojo.js (line 1333)
(no name)(Object _S=Object _0=2 name=[1] _RI=true nodeId=[1], null)dojo.js (line 1352)
log()dojo.js (line 20)
log()dojo.js (line 20)
(no name)(Object nodeId=3 name=node3 parentId=0, Object store=Object root=true id=treeRoot label=Selection)dojo.js (line 203)
newItemz(Object store=Object root=true id=treeRoot label=Selection)Imax2 (line 43)
(no name)(Object store=Object root=true id=treeRoot label=Selection, function(), function())dojo.js (line 1229)
(no name)([Widget dijit._TreeNode, dijit__TreeNode_0] _connects=[1] _attaches=[0] params=Object)dojo.js (line 775)
(no name)(Object store=Object root=true id=treeRoot label=Selection)dojo.js (line 471)
log()dojo.js (line 20)
(no name)(function(), function())dojo.js (line 981)
(no name)()dojo.js (line 473)
(no name)()dojo.js (line 404)
(no name)(Object model=Object showRoot=false id=myTree, div#myTree)dojo.js (line 160)
(no name)(Object model=Object showRoot=false id=myTree, div#myTree)dojo.js (line 84)
log([Object model=Object showRoot=false id=myTree, div#myTree])dojo.js (line 20)
log()dojo.js (line 20)
(no name)(div#myTree)dojo.js (line 208)
log([div, div, div#myTree, 1 more...], function(), undefined)dojo.js (line 20)
(no name)([div, div, div#myTree, 1 more...])dojo.js (line 149)
(no name)(undefined)dojo.js (line 250)
(no name)()dojo.js (line 261)
log()dojo.js (line 20)
log()dojo.js (line 20)
log()dojo.js (line 20)
log(load )dojo.js (line 20)
[Break on this error] undefined
Help Dino