PDA

View Full Version : TreePanel, load child nodes from local data (not from server)



morlok_is_back
27 May 2010, 2:21 PM
Hi,

I try write custom variable debuger. Properties of variable (if it is object) a like to open in treePanel. After click any node i need open child nodes. Problem is TreePanel for load childrens using treeLoader. How configure TreePanel or TreeLoader... or is any other way to load child nodes from local data (not from server).

Thanx for any help

morlok_is_back
27 May 2010, 3:04 PM
Problem solved,

Solution: write custom load metod for TreeLoader and in load method create node childrens and call callback.

MarkMYoung
1 Jun 2010, 11:22 AM
morlok_is_back, please share your solution. I knew I needed to extend the TreeLoader and override 'load', at a minimum, before I found your post.

Thanks in advance,
Mark

morlok_is_back
8 Jun 2010, 4:24 AM
// this is part of my code, i do object debuger, then data are any variable, and loader load child vraiables in tree
// most important is call cb() in end of load metod


var loader = new Ext.tree.TreeLoader();
loader.load = function(node, cb) {
if(node.leaf) {
cb();
return ;
}

var cfg;
var val = node.attributes.debugValue;
var type = Ext.type(val);

if(type == 'object') {
for(var x in val) {
cfg = this.describeNode(Ext.type(val[x]), val[x], x);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
} else if(type == 'array') {
for(var x in val) {
cfg = this.describeNode(Ext.type(val[x]), val[x], x);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
} else { alert('simple');
cfg = this.describeNode(type, val);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
cb();
}

morlok_is_back
8 Jun 2010, 4:27 AM
// this is part of my code, where i debuging any variable. Loader async. loading child nodes of object.
// most important is call cb() function on end laod function.

var loader = new Ext.tree.TreeLoader({
showFunctions: this.showFunctions
});
loader.load = function(node, cb) {
if(node.leaf) {
cb();
return ;
}

var cfg;
var val = node.attributes.debugValue;
var type = Ext.type(val);

if(type == 'object') {
for(var x in val) {
cfg = this.describeNode(Ext.type(val[x]), val[x], x);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
} else if(type == 'array') {
for(var x in val) {
cfg = this.describeNode(Ext.type(val[x]), val[x], x);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
} else { alert('simple');
cfg = this.describeNode(type, val);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
cb();
}

morlok_is_back
8 Jun 2010, 4:28 AM
// this is part of my code, where i debuging any variable. Loader async. loading child nodes of object.
// most important is call cb() function on end laod function.

var loader = new Ext.tree.TreeLoader({
showFunctions: this.showFunctions
});
loader.load = function(node, cb) {
if(node.leaf) {
cb();
return ;
}

var cfg;
var val = node.attributes.debugValue;
var type = Ext.type(val);

if(type == 'object') {
for(var x in val) {
cfg = this.describeNode(Ext.type(val[x]), val[x], x);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
} else if(type == 'array') {
for(var x in val) {
cfg = this.describeNode(Ext.type(val[x]), val[x], x);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
} else { alert('simple');
cfg = this.describeNode(type, val);
if(cfg) {
node.appendChild(new Ext.tree.AsyncTreeNode(cfg));
}
}
cb();
}