marklar
3 Apr 2007, 2:32 PM
I have to use an ugly hack in order to get the tree loader to work correct doing an async load from a server which wants the node parameter.
Here is the root of the problem I am running into:
The Ext.tree.TreeLoader requestData function calls getParams:
var params = this.getParams(node);
The getParams function seems to always return a string as the last line is:
return buf.join(""); //string only right?
The Ajax request function seems to want a params object and does not take a string.
Note: I hard coded the below statement and it did pass the values into the agents query_string. When I hard coded a string it did not work. This is making me think the Ext.lib.Ajax.request function wants an object for params not a string (at least in field=value format).
params = {node2:'demo'}; //works
params = 'node2=demo'; //does not work
Here is the code I use to hack in a fix - please help
//--- fix for bug or incorrect usage :) of async tree
Ext.tree.TreeLoader.prototype.requestData = function(node, callback){
if(this.fireEvent("beforeload", this, node, callback) !== false){
var params = this.getParams(node);
var cb = {
success: this.handleResponse,
failure: this.handleFailure,
scope: this,
argument: {callback: callback, node: node}
};
if (typeof params == 'object'){
this.transId = Ext.lib.Ajax.request(this.requestMethod, this.dataUrl, cb, params);
} else {
this.transId = Ext.lib.Ajax.request(this.requestMethod , this.dataUrl + '&' + params, cb, params);
}
}else{
if(typeof callback == "function"){
callback();
}
}
}
If I need to provide more details or better examples, let me know.
Thanks for your help.
Joseph
Here is the root of the problem I am running into:
The Ext.tree.TreeLoader requestData function calls getParams:
var params = this.getParams(node);
The getParams function seems to always return a string as the last line is:
return buf.join(""); //string only right?
The Ajax request function seems to want a params object and does not take a string.
Note: I hard coded the below statement and it did pass the values into the agents query_string. When I hard coded a string it did not work. This is making me think the Ext.lib.Ajax.request function wants an object for params not a string (at least in field=value format).
params = {node2:'demo'}; //works
params = 'node2=demo'; //does not work
Here is the code I use to hack in a fix - please help
//--- fix for bug or incorrect usage :) of async tree
Ext.tree.TreeLoader.prototype.requestData = function(node, callback){
if(this.fireEvent("beforeload", this, node, callback) !== false){
var params = this.getParams(node);
var cb = {
success: this.handleResponse,
failure: this.handleFailure,
scope: this,
argument: {callback: callback, node: node}
};
if (typeof params == 'object'){
this.transId = Ext.lib.Ajax.request(this.requestMethod, this.dataUrl, cb, params);
} else {
this.transId = Ext.lib.Ajax.request(this.requestMethod , this.dataUrl + '&' + params, cb, params);
}
}else{
if(typeof callback == "function"){
callback();
}
}
}
If I need to provide more details or better examples, let me know.
Thanks for your help.
Joseph