PDA

View Full Version : Paging Toolbar with params and GET-Request



mindreframer
23 Apr 2007, 10:28 AM
Hello, I'm using the great Grid-Widget in combination with a restful Rails-App, and the controller responds with create action on a POST-request. So when using paging toolbar, it tries to load the json-data via posting the params, but instead of grid-data the server sends an error-page for trying to create an empty object from the params....

I've looked in the code and this is the relevant part of deciding wheter to POST or GET (copypaste from the Firebug window)


Ext.extend(Ext.data.Connection, Ext.util.Observable, {

timeout : 30000,

request : function(options){

if(this.fireEvent("beforerequest", this, options) !== false){

var p = options.params;

if(typeof p == "object"){

p = Ext.urlEncode(Ext.apply(options.params, this.extraParams));

}

var cb = {

success: this.handleResponse,

failure: this.handleFailure,

scope: this,

argument: {options: options},

timeout : this.timeout

};
debugger;

var method = options.method||this.method||(p ? "POST" : "GET");

var url = options.url || this.url;

if(this.autoAbort !== false){

this.abort();

}

if(method == 'GET' && p){

url += (url.indexOf('?') != -1 ? '&' : '?') + p;

p = '';

}

this.transId = Ext.lib.Ajax.request(method, url, cb, p);

}else{

if(typeof options.callback == "function"){

options.callback.call(options.scope||window, options, null, null);

}

}

},

(extjs-all-debug, starting around 9815-9820)
the var method (
var method = options.method||this.method||(p ? "POST" : "GET");
) is if any params present, POST, so my question:
is there a clean way to enforce GET-request from the paging toolbar to the connection-object?
It would be really nice, since I don't like messing with the core code. Any advice is highly appriciated =P~
Maybe setting the options.methods directly? Thanks!

tryanDLS
23 Apr 2007, 11:50 AM
You can pass it on the proxy. See this thread (http://extjs.com/forum/showthread.php?t=2670&highlight=options.method)

mindreframer
23 Apr 2007, 3:42 PM
Thanks, that worked! :D :D :D