View Full Version : ExtJS TreePanel mixed style - async and static

1 Jun 2011, 10:04 AM
I spent my first half of day trying to figure out how to create treePanel where every other level is statically loaded in higher level async load.

It is necessary because each pair level has different meaning and to save server resources I load data in one ajax for two levels.

Root is AsyncTreeNode.
First level is simple TreeNode.
Second level is again AsyncTreeNode.

To accomplish this I override createNode function in TreeLoader:

this.treeLoader = new Ext.tree.TreeLoader({
dataUrl: 'data.php',
baseParams: { }
,createNode : function(node){
node.text = node.name;
if (typeof(node.sub)!='undefined') {
node.text += ' ('+ node.sub.length +')'; // sub level count
} else {
node.leaf = true; // if no then create as leaf
a = new Ext.tree.TreeNode(node); // I create simple TreeNode manualy
for (var i in node.sub) { // sub is array from server where level names ar stored
if (i=='remove') break; // wtf! ExtJS :)
a.appendChild(new Ext.tree.AsyncTreeNode({text:node.sub[i].text})); // append all children
return a; // return the node
//return Ext.tree.TreeLoader.prototype.createNode.call(this, node); // do not return in standard way

19 Oct 2011, 3:54 AM

I saw this sollution and it is exactly what I want, but I'm using jsExt 4.
I could try to migrate the code, but the problem is that I don't see config properties like 'dataUrl', 'typeof', or the component 'AsyncTreeNode', which are essential to accomplish this.
Perhaps there is no possibility to to an async tree node in ExtJs?

Any help would be appreciated,

Best regards,