django - ExtJs 4 Add records to the grid from JSON -



django - ExtJs 4 Add records to the grid from JSON -

i'm new extjs user, , have next problem. i'm trying load info extjs grid, serialized json on server (i utilize django serialize() method), i'm getting empty grid. problem seems in callback function, loads info grid, can't solve it.

here code:

controller-function

renderstudentlist:function(){ var ul = this.getstore('users'); ul.load({ scope :this, callback : function(records, operation, success){ for(i in records){ /* here, think, should code assigns values json grid records */ console.log(records[i].get('fields').name, records[i].get('fields').email); } } }); }

json-data, server

{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"}}]}

my model

ext.define('am.model.user', { extend: 'ext.data.model', idproperty: 'pk', fields: [{ name:'pk', type:'integer' },{ name: 'fields', type: 'object' }] });

my store

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' } } });

thanks all!

i think json should if not wrong:

{success:true, "students":[{"pk": 1, "fields": {"name": "bob", "email": "bob@mail.ua"}}, {"pk": 2, "fields": {"name": "sam", "email": "sam@gmail.com"}}]}

this done in python this: after recieve json string: in json string;

actual_data = [d['students']['pk'], d['fields'] d in json] output = "{" output += "success: true" output += json.dumps(actual_data) output += "}" homecoming httpresponse(output)

django json extjs proxy grid

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -