How to change request URI in Proxy or Reader ExtJS 4.1.0

As with ExtJS 4.1 with a Rest proxy and a Json reader, a URI is requested similar to this (urlencoded, though):

http://localhost:8000/api/v1/choice/?filter=[{"property":"question_id","value":2}]

My server wants filter requests to look like this:

http://localhost:8000/api/v1/choice/?question_id=2

I looked at the configuration filterParamfor the proxy server, but this does not seem relevant. Is there a practical way to achieve the request URI that the server needs?

+3
source share
2 answers

The following is ugly, but it works. Now, to fix the damn store ...

/**
         * Customized to send ../?prop=val&prop2=val2 urls.
         */
        buildUrl: function(request) {
            var url = this.url;
            var filters = eval(request.params['filter']);
            if (filters) {
                delete request.params['filter'];
                url += '?'
                for (var i = 0; i < filters.length; i++) {
                    var filterString = filters[i].property + "=" + filters[i].value;
                    if (url.slice(url.length-1) === '?') {
                        url += filterString;
                    } else {
                        url += '&' + filterstring;
                    } 
                }
            };
            return url;
        },
+2
source

() . Proxy. Ext.data.proxy.Proxy Ext.data.proxy.Server. getParams buildUrl

+1

All Articles