-
21 Jan 2013 11:20 AM #1
Unanswered: Create a Store from a subset of JSON Store
Unanswered: Create a Store from a subset of JSON Store
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
-
21 Jan 2013 5:43 PM #2
Try defining your data using several models and use the "hasMany" association for the accountNumbers.
I'm not sure I've got the code correct but you should get the idea.Code: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' } );
Check the docs: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Model
Worth


Reply With Quote