PDA

View Full Version : data.store and params/baseParams



jg4smile
13 Jul 2007, 5:07 PM
Newbie question:

I am attempting to filter a data.store object with URL parameters and from what I am reading, I believe it can be done by using "params". See snippet below:



var ds2 = new Ext.data.Store({
// proxy: new Ext.data.HttpProxy({url: 'testData.aspx?Region=BIR'}),
proxy: new Ext.data.HttpProxy({url: 'testData.aspx'}),
reader: new Ext.data.XmlReader({
record: 'Region',
id: 'StoreID',
totalRecords: '@total'
}, [
{name: 'Region'},
{name: 'StoreID'},
{name: 'StoreName'}
]),
params:{ Region: 'BIR' }
});

ds2.load();


I am wondering if the block of code "params:{ Region: 'BIR' } " is the same as "?Region=BIR"? Ultimately this store will be a filtered list for a combo box. Any help will be appreciated.

jg4smile
13 Jul 2007, 6:15 PM
okay, for any newbie that wants to know, "params" is treated as a form field and not a url parameter. I feel like an , but with a little more work, i'll hopefully build my reputation in here and contribute something in the meantime.

aconran
15 Jul 2007, 6:20 PM
jg4smile -
The key here is that the default http method of Ext.data.HttpProxy is 'POST'. Therefore params will come through as form fields. If you changed this http method to 'GET' the params would be sent as URL params.

For example:


proxy: new Ext.data.HttpProxy({url: 'testData.aspx', method: 'GET'}),



HttpProxy's documentation here (http://extjs.com/deploy/ext/docs/output/Ext.data.HttpProxy.html) specifies that all Ext.data.Connection config options are relevant options. You can look at all the configuration options for a data connection here (http://extjs.com/deploy/ext/docs/output/Ext.data.Connection.html#configs).

Hope this helps,
Aaron Conran

jg4smile
17 Jul 2007, 7:37 AM
thanks, aconran! seriously, that information has opened up a lot new doors.