Hello folks:
My JSON looks like this:
In my controller I make a call to the proxy and I do get a successful callback
I can get the store, I can get the model from the first piece of data in the store. Now I want to get the store with the cisoSystemLoadModelList from that model. The mainGridModel comes back non-null but the data attribute seems to be empty. How can I get a reference to that data?
How do I get data from a store which uses a model with HasMany lists?
I'm trying to view data in a model via a JSON proxy which has several list in it.
My model looks like this:
Code:
Ext.define('PeakDay.model.MainGridModel', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.Field'
],
hasMany: [
{
name: 'cisoSystemLoadModelList',
model:'CISOSystemLoadModel',
associationKey:'cisoSystemLoadModelList'
},
{
name: 'interchangeAtPeakModelList',
model:'InterchangeAtPeakModel',
associationKey:'interchangeAtPeakModelList'
},
// and so on
My JSON looks like this:
Code:
{
"cisoSystemLoadModelList": [
{
"sortOrder": 0,
"title": "Peak Demand",
"mw": "38,712",
"time": "16:55",
"asOfTime": "5/29/2014 2:25:58 PM",
"groupName": ""
},
{
"sortOrder": 1,
"title": "Minimum Demand",
"mw": "22,942",
"time": "3:47",
"asOfTime": "5/29/2014 2:25:58 PM",
"groupName": ""
},
{
"sortOrder": 2,
"title": "Scheduled Load",
"mw": "32,516",
"time": "84%",
"asOfTime": "5/29/2014 2:25:58 PM",
"groupName": ""
},
{
"sortOrder": 3,
"title": "Pump Load",
"mw": "290",
"time": "",
"asOfTime": "5/29/2014 2:25:58 PM",
"groupName": ""
}
]
}
In my controller I make a call to the proxy and I do get a successful callback
Code:
var mainGridSheetStore = Ext.StoreMgr.lookup('MainGridSheetStore');
var queryDate = 'TODAY';
mainGridSheetStore.load({
params: { 'queryDate': queryDate },
callback: function(records, operation, success) {
if (success) {
var mainGridSheetStore = Ext.StoreMgr.lookup('MainGridSheetStore');
var mainGridModel = mainGridSheetStore.data.first();
var cisoStore = mainGridModel.data.cisoSystemLoadModelList;
// and so on
I can get the store, I can get the model from the first piece of data in the store. Now I want to get the store with the cisoSystemLoadModelList from that model. The mainGridModel comes back non-null but the data attribute seems to be empty. How can I get a reference to that data?
Thank you
Greg
How do I get data from a store which uses a model with HasMany lists?
Aucun commentaire:
Enregistrer un commentaire