Hybrid View
-
12 Aug 2008 2:54 PM #1
[FIXED-278][2.x,3.x] AsyncTreeNode's loader is overridden by the one from treePanel
[FIXED-278][2.x,3.x] AsyncTreeNode's loader is overridden by the one from treePanel
We found Ext 2.2 starts to support literal config for TreeNode, AsyncTreeNode and TreeLoader. That helps us a lot and thank you!
Here is still a problem on AsyncTreeNode's TreeLoader. For example:
var tree = new Ext.tree.TreePanel({
xtype: 'treepanel',
el:'tree',
animate:true,
autoScroll:true,
containerScroll:true,
autoHeight: true,
loader: {dataUrl: "http://server/webapps/treePanel.jsp"},
root:
{
text: 'root2',
draggable:false, // disable root node dragging
loader: {dataUrl: "http://server/webapps/treeNode.jsp"},
id:'root',
expanded: true
}
});
tree.render();
});
"http://server/webapps/treeNode.jsp" never gets called. The same thing applies to all the children nodes. Even if they have different loader configured, Ext still uses TreePanel's loader to create the next level nodes.
Debug through the source codes, I found two suspicious places:
1. In TreeLoader.js
...
createNode : function(attr){
// apply baseAttrs, nice idea Corey!
if(this.baseAttrs){
Ext.applyIf(attr, this.baseAttrs);
}
if(this.applyLoader !== false){
attr.loader = this;
}
...
It seems like it doesn't honor node's own loader. what is "applyLoader" used for?
2. In AsyncTreeNode.js
Ext.tree.AsyncTreeNode = function(config){
this.loaded = config && config.loaded === true;
this.loading = false;
Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
/**
* @event beforeload
* Fires before this node is loaded, return false to cancel
* @param {Node} this This node
*/
this.addEvents('beforeload', 'load');
/**
* @event load
* Fires when this node is loaded
* @param {Node} this This node
*/
/**
* The loader used by this node (defaults to using the tree's defined loader)
* @type TreeLoader
* @property loader
*/
};
It mentions the loader, but doesn't initialize it from "config", why?
I made two changes at these places and it seems make it work:
1.
...
if(this.applyLoader !== false){
attr.loader = attr.loader || this;
}
...
2.
...
var l = config.loader;
if(!l){
l = new Ext.tree.TreeLoader({
dataUrl: this.dataUrl
});
}else if(typeof l == 'object' && !l.load){
l = new Ext.tree.TreeLoader(l);
}
this.loader = l;
...
Not sure if these are right fixes though.
-
16 Aug 2008 8:13 AM #2
Do you think this is a bug? I can move this thread to Bugs forum then.
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
18 Aug 2008 9:44 AM #3
Can you confirm this is a bug or we just use it wrong? If yes, sure, you can move it to the right place.
-
18 Aug 2008 10:15 AM #4
I haven't tested it personally but if node's loader is not called but the tree's one, as you say, it looks like bug. If nowhere else then in docs.
Moving the thread to bugs.Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
28 Aug 2008 7:55 AM #5
I think this is a bug, I am experiencing the same phenomenon. I cannot define different Treeloaders for different nodes in a tree...
-
28 Aug 2008 8:21 AM #6
Agreed, the tree loader should only inherit if the node hasn't specified a loader.
However, if there is no loader defined on a node and the parent node has a loader, which loader should the node use? It would be most logical for it to be the loader of the parent.Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
28 Aug 2008 9:54 AM #7
I think it is more logical to use parent's loader than to use treePanel's one.
-
28 Aug 2008 11:54 AM #8
I agree. That way you can have branches loaded from different loaders which offers flexibility. I seem to remembert posting a Feature Request about this.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
28 Aug 2008 11:55 AM #9Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote