мой вывод json:
{"Result":
{"Data":
[{"gmt_id":"1","gmt":"-12:00","secondsDiff":"-43200","Location":"Baker IslanIsland"},
{"gmt_id":"2","gmt":"-11:00","secondsDiff":"-39600","Location":"American Samoa, Samoa"},
{"gmt_id":"3","gmt":"-10:00","secondsDiff":"-36000","Location":"Hawaii, Papeete"}]}}
- Я хочу, чтобы моя Модель была вложена с Результатом и Данными, чтобы при установке autoLoad: true в хранилище, доступ к ключу: значение в потоке. Но мой console.log дает []. я ошибаюсь где-то в моей модели, пожалуйста, помогите !!!
- это моя модель
Ext.regModel('Gmt',
{'Result':
{'Data':
[
{name:'gmt_id',type:'string'},
{name:'Location',type:'string'}
]
}
});
Это мой магазин для загрузки данных:
var jsonStore = new Ext.data.Store({
model: "Gmt",
proxy: {
type: 'ajax',
url: 'gmt.php',
//url: 'data.json',
method: 'GET',
// callback: console.log(response),
reader: {
type: 'json',
//root: 'Data'
root:'Result'
// type:'json'
},
afterRequest: function (request, success) {
if (success) {
console.log("success");
} else {
console.log("failed");
}</p>
<pre><code> }
},
autoLoad: true
});
</code>
- ключ доступа: значения параметров здесь
jsonStore.on('load', function(){
var lstArr = new Array();
var lstAr = new Array();
jsonStore.each(function(i) {
//var gmtdata = i.data.gmt_id;
// console.log(i);
lstArr.push(i.data.gmt_id);
lstAr.push(i.data.Location);
});
console.log(lstArr);
console.log(lstAr);
});