PDA

View Full Version : Model and Re-execution of a Proxy



JoePie
6 Jan 2012, 5:11 PM
I have two models defined.

Data from Model 1 (GridUser) is displayed in Grid1.
Data from Model 2 (Product) is displayed in Grid2.

I have attached a listener in Grid1 which operates on an ItemDblClick to obtain the value of the variable Company.

I would like to modify the URL associated with Model 2 as shown in the ProductStore Proxy based on the Company value so that the Proxy re-executes with the modified value of Company.

The code for both the models and their associated stores is attached.



Ext.define('GridUser', {
extend:'Ext.data.Model',
fields: [
{ name: 'company' },
{ name: 'price', type: 'float' },
{ name: 'change', type: 'float' },
{ name: 'pctChange', type: 'float' }
]
});



Ext.define('Product', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'user_id', type: 'int'},
{name: 'name', type: 'string'}
]
});

var store1 = new Ext.data.ArrayStore({
model: 'GridUser',
proxy: {
type: 'ajax',
url: ('THIS IS THE URL TO THE DATA FILE'),
reader: 'json'
},
autoLoad: true
});

var ProductStore = new Ext.data.ArrayStore({
model: 'Product',
proxy: {
type: 'ajax',
url: ('THIS URL NEEDS TO BE MODIFIED BASED ON THE VALUE OF THE VARIABLE COMPANY FROM THE MODEL GRIDUSER'),
reader: 'json'
},
autoLoad: true
});

mitchellsimoens
7 Jan 2012, 6:18 AM
All you should have to do is once you have your store, get the proxy off of it and change the url property.