PDA

View Full Version : Create a Store from a subset of JSON Store



tharahan
21 Jan 2013, 11:20 AM
Hi

I have a json store defined as follows

var subAccountStore = new Ext.data.JsonStore({
autoLoad: true,
proxy: {
type:'ajax',
url : '/opUI/json/subaccount.action?name="ABC"'
},
fields: ['accountName', 'quantity','accountNumbers'],
listeners: {
load: function(store, records, success) {
// ???????
},
single: true
}

});

and sample data is

[{"accountName":"'ABC'","quantity":100,"accountNumbers":['12345A','12345B','12345C']},{"accountName":"'XYZ'","quantity":100,"accountNumbers":['99999A','99999B','99999C']}]

How do I create a store dynamically for "accountNumbers" and assign to combo box inside the grid?

Thanks
Tharahan

worthlutz
21 Jan 2013, 5:43 PM
Try defining your data using several models and use the "hasMany" association for the accountNumbers.



Ext.define('MyApp.model.AccountNumbers',
fields: [
{ name: 'accountNumber'
}
],
belongsTo: 'MyApp.model.Accounts',
);

Ext.define('MyApp.model.Accounts',
fields: [
{ name: 'accountNumber' },
{ name: 'quantity'}
],
hasMany: {
name: 'accountNumbers',
model: 'myApp.model.AccountNumber'
}
);


I'm not sure I've got the code correct but you should get the idea.
Check the docs: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Model

Worth