Alex Chan
Alex Chan

Reputation: 1032

How to perform RESTful request through rest proxy in Sencha Touch2

I'd like to perform a RESTful get request like

"/commments/123" <br/>

but it always request addtional parameters like this

:<br/>
" _dc=1337095865783&page=1&start=0&limit=25" <br/>

Please tell me how to convert the addtional parameters to RESTful request

Upvotes: 1

Views: 3853

Answers (1)

Eric C
Eric C

Reputation: 832

You can remove extra parameters being added by Sencha automatically by setting any of the xxxParam options to false on the proxy object (limitParam, enablePagingParams, startParam, etc) and also disable the _dc cache querystring with noCache:

proxy: {
    type: 'rest',
    url: '/comments',
    noCache: false,
    limitParam: false,
    enablePagingParams: false,
    startParam: false
}

If you're following the model/store structure of Sencha, then you can just make a rest proxy for your store and tell it to include the id (which it does by default):

new Ext.data.Store({
    model: "comments",
    autoLoad: false,
    proxy: {
        type: 'rest',
        url: '/comments',
        appendId: true, //default
        noCache: false,
        limitParam: false,
        enablePagingParams: false,
        startParam: false
    }
});

// Collection url: /comments
// Instance url  : /comments/123

Lastly, you can use the buildUrl method on the proxy to create a custom Url format for the request.

Reference http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.Rest for more details.

Upvotes: 4

Related Questions