Is there any way to specify headers (specifically, the accept header) with a treepanel?
I do not wish to override the headers used globally with EXT, just the ones specifically for an instance of treepanel.
Thanks for the help!
Printable View
Is there any way to specify headers (specifically, the accept header) with a treepanel?
I do not wish to override the headers used globally with EXT, just the ones specifically for an instance of treepanel.
Thanks for the help!
Clear language: Are you talking about HTTP headers?
You will have to extend Ext.tree.TreeLoader, and implement your own requestData method.
IMHO, this method should be fully documented so that people can plug in their own imlpementations easily. It's not difficult though, just take a look at the source.
Hmm. I'm a bit confused.
Other components allow me to specify headers as an object. Is there any way I can do this without extending the class? Maybe just by decorating it or overriding some aspect of it?
Just trying to look for the simplest solution...
OK, now I'm confused. What other components allow you to specify headers as an object? Just so I understand what you mean.
myForm.getForm().load({
method: "GET",
url: "MyURL",
success : function() {
pageEditor.el.unmask();
},
// Specify custom headers.
headers: {
// Inform the server that we're saving as part of an ext-js FormPanel object's lifecycle.
"Accept": "blah/blahblahblah"
}
});
Right, extend and override this
Code:
requestData : function(node, callback, scope){
if(this.fireEvent("beforeload", this, node, callback) !== false){
if(this.directFn){
var args = this.getParams(node);
args.push(this.processDirectResponse.createDelegate(this, [{callback: callback, node: node, scope: scope}], true));
this.directFn.apply(window, args);
}else{
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, scope: scope},
params: this.getParams(node)
});
}
}else{
// if the load is cancelled, make sure we notify
// the node that we are done
this.runCallback(callback, scope || node, []);
}
},
How or where exactly would I put this code?
Also, bear in mind the example I gave you was for a FormPanel as an example. I want to add an HTTP accept-header to a TreePanel's async request.