Я новый пользователь ExtJS, и у меня возникла следующая проблема. Я пытаюсь загрузить некоторые данные в сетку ExtJS, которая сериализуется на сервере json (я использую метод django serialize ()), но я получаю пустую сетку. Кажется, проблема в функции обратного вызова, которая загружает данные в сетку, но я не могу ее решить.
Вот мой код:
Контроллер-функция
renderStudentList:function(){
var ul = this.getStore('Users');
ul.load({
scope :this,
callback : function(records, operation, success){
for(i in records){
/* here, i think, should be a code that assigns values from json to the grid records */
console.log(records[i].get('fields').name, records[i].get('fields').email);
}
}
});
}
JSON-данные, которые я получаю с сервера
{success:true, "students":[{"pk": 1, "model": "poll.student", "fields": {"name": "Bob", "email": "bob@mail.ua"}}, {"pk": 2, "model": "poll.student", "fields": {"name": "Sam", "email": "sam@gmail.com"}}]}
моя модель
Ext.define('AM.model.User', {
extend: 'Ext.data.Model',
idProperty: 'pk',
fields: [{
name:'pk',
type:'integer'
},{
name: 'fields',
type: 'object'
}]
});
мой магазин
Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
// autoLoad: true,
proxy: {
type: 'ajax',
api: {
read: '/ex/'
},
reader: {
idProperty: 'pk',
type: 'json',
root: 'students',
successProperty: 'success'
}
}
});
Спасибо всем!