PDA

View Full Version : [2.0b1] Ext.tree.TreeLoader enhancement



nervo
16 Oct 2007, 4:25 AM
In file source\widgets\tree\TreeLoader.js, near line 171 :


requestData : function(node, callback){
if(this.fireEvent("beforeload", this, node, callback) !== false){
this.transId = Ext.Ajax.request({
method:this.requestMethod,
url: this.dataUrl||this.url,
success: this.handleResponse,
failure: this.handleFailure,
scope: this,
argument: {callback: callback, node: node},
params: this.getParams(node)
});
}else{
// if the load is cancelled, make sure we notify
// the node that we are done
if(typeof callback == "function"){
callback();
}
}
},Maybe, to use Ext.Ajax.url by default, if url TreeLoader param is not present, the following lines could be modified :


requestData : function(node, callback){
if(this.fireEvent("beforeload", this, node, callback) !== false){
this.transId = Ext.Ajax.request({
method:this.requestMethod,
url: this.dataUrl||this.url||Ext.Ajax.url,
success: this.handleResponse,
failure: this.handleFailure,
scope: this,
argument: {callback: callback, node: node},
params: this.getParams(node)
});
}else{
// if the load is cancelled, make sure we notify
// the node that we are done
if(typeof callback == "function"){
callback();
}
}
},

And, indeed, near line 126 :


load : function(node, callback){
if(this.clearOnLoad){
while(node.firstChild){
node.removeChild(node.firstChild);
}
}
if(this.doPreload(node)){ // preloaded json children
if(typeof callback == "function"){
callback();
}
}else if(this.dataUrl||this.url){
this.requestData(node, callback);
}
},

to :


load : function(node, callback){
if(this.clearOnLoad){
while(node.firstChild){
node.removeChild(node.firstChild);
}
}
if(this.doPreload(node)){ // preloaded json children
if(typeof callback == "function"){
callback();
}
}else if(this.dataUrl||this.url||Ext.Ajax.url){
this.requestData(node, callback);
}
},

mystix
16 Oct 2007, 4:36 AM
:-/ why is this a bug?

p.s. have you read 13985?

nervo
16 Oct 2007, 6:12 AM
As said in the title, it's not really a bug, it's an enhancement...
But you can see it as a bug if you read 2.0 API doc in Ext.Ajax public class properties :


url : String
The default URL to be used for requests to the server. (defaults to undefined)

In this way, Ex.tree.TreeLoader breaks the "default" aspect of Ext.Ajax.url property

mystix
16 Oct 2007, 6:35 AM
:-/ i don't understand... care to explain in detail?

p.s. looks like one of the moderators has already moved this thread to it's proper place -- the Open Discussion forum.

p.s.s do take a look at the bug posting guidelines just to be sure you're posting stuff in the right place. thanks. :)