PDA

View Full Version : How to remove page start limit query string attributes



asatishkumar
22 Jun 2012, 1:44 PM
I am using sencha Ext JS 4.x, I have a grid panel that uses a REST proxy to retrieve data, When I debug using Chrome, the REST URL is getting uppended with the following, page=1&start=0&limit=25, which is causing the REST URL to be unrecognizable on the server side with a 405 error. How can I prevent this from being added.

khmurach
23 Jun 2012, 12:14 AM
Which url format for paging is accepted by your server side?

asatishkumar
23 Jun 2012, 5:07 AM
Unfortunately, the server doesn't accept any paging attributes. Do you think it's necessary to modify the REST end points to recognize the additional query string parameters or is there a way in Sencha to strip these off before making the request?

khmurach
23 Jun 2012, 6:44 AM
Code to remove params:


proxy: {
type: 'rest',
pageParam: false, //to remove param "page"
startParam: false, //to remove param "start"
limitParam: false, //to remove param "limit"
noCache: false, //to remove param "_dc"
url: '/User'
}

Demo here http://ext4all.com/post/how-to-remove-page-start-limit-query-string-params

asatishkumar
25 Jun 2012, 5:59 AM
No luck yet. I am using Sencha Architect and here's what the code looks like, The URL from Chrome still adds the additional attributes, http://circinis.winwholesale.com/RESTfulUserInfo/username/skumar?page=1&start=0&limit=25


Ext.define('MyApp.store.compds', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.Company'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
storeId: 'compds',
model: 'MyApp.model.Company',
proxy: {
type: 'rest',
limitParam: 'false',
noCache: false,
pageParam: 'false',
startParam: 'false',
url: 'http://circinis.winwholesale.com/RESTfulCoAccess/username/kmdisken',
appendId: false,
reader: {
type: 'xml',
root: 'companyAccessList',
record: 'company'
}
}
}, cfg)]);
}
});

asatishkumar
25 Jun 2012, 6:58 AM
Sorry, the URL really looks like this, don't know what the "false" parameter is for?,

http://circinis.winwholesale.com/RESTfulCoAccess/username/kmdisken?false=25

asatishkumar
25 Jun 2012, 7:18 AM
It also get the following error in Chrome. Any thoughts on overcoming this would be appreciated as well,

XMLHttpRequest cannot load http://circinis.winwholesale.com/RESTfulUserInfo/username/skumar?false=25. Origin http://localhost:8090 (http://localhost/) is not allowed by Access-Control-Allow-Origin.

khmurach
25 Jun 2012, 8:46 AM
Use not string values:

limitParam: 'false',
pageParam: 'false',
startParam: 'false',

but boolean values:

limitParam: false,
pageParam: false,
startParam: false,

khmurach
25 Jun 2012, 8:50 AM
> It also get the following error in Chrome.
Your page on localhost calls to another domain - this is cross-domain request which is not allowed in Ext.data.Store.

asatishkumar
25 Jun 2012, 11:00 AM
How do we create a test version of the application that consumes production REST services if Ext.data.store doesn't support XHR calls? I tried to use the
--disable-web-security start up parameter for the Chrome browser and it didn't help either

khmurach
25 Jun 2012, 10:21 PM
Do you have local rest service?

asatishkumar
26 Jun 2012, 4:33 AM
Unfortunately no..However I have found a work around. I am using Internet Explorer to over come this difficulty. I am still in the evaluation phase of Sencha. So, this might play a role in our decision making process.

jambi
26 Jul 2012, 4:41 AM
On the Proxy configuration, instead of setting pageParam to false, try setting pageParam to undefined.

* I'm using Architect, so in the "Ext.data.proxy.Server" property section, I set pageParam to an empty string. Otherwise, it will default to "page".

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Server-cfg-pageParam (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.proxy.Server-cfg-pageParam)

scottw@cashwa.com
3 Apr 2014, 1:34 PM
In Architect 3 you will have to set each param (limitParam, pageParam, sortParam) to a space " " then go back to each one and backspace the value out. Clicking the X will just put the defaults back in and typing the word undefined won't work.

This will set your config like the following:

proxy: {
limitParam: '',
pageParam: '',
startParam: '',
}

...and should give you the desired effect you are looking for.