PDA

View Full Version : Populating grid panel dynamically



neri alamanni
10 Jan 2013, 12:25 AM
Hi all
I am trying to populate dynamically a grid panel. I.e no model with static definition of fields is used. The grid columns are created on the fly and the grid should be filled extracting from JSON response from the server those parameters matching the column names. But nothing but the column names appers on the grid.
The code fragment supposed to populate the grid is:
// reset manager store
mgr_grid=Ext.ComponentQuery.query('managergrid')[0];
store=mgr_grid.getStore();
store.loadData([],false);

var cols=[];


var item2 = {};
item2.xtype = 'gridcolumn';
item2.text = "_id";
item2.dataIndex = '_id';
cols.push (item2);
var item2 = {};
item2.xtype = 'gridcolumn';
item2.text = "_name";
item2.dataIndex = '_name';
cols.push (item2);
store.getProxy().url = record.raw.link; //the url is valid
mgr_grid.reconfigure(store, cols);

the content JSON response is like:

items: [{_status:{success:true, message:null, code:0},}, {_status:{success:true, message:null, code:0},},]

0: {_status:{success:true, message:null, code:0},}

_created: 1262300401000
_createdBy: "admin"
_description: ""
_id: "CLL-21"
_isLocked: false
_links: {versions:{title:Versions for Class lifecycle 'Entity', name:Versions,},}
_lockComment: null
_lockUsername: null
_modified: 1262300401000
_modifiedBy: "admin"
_name: "Entity"..



Where is my error? Am I trying to do something possible?
Thank you
best regards
Neri Alamanni

mitchellsimoens
11 Jan 2013, 12:38 PM
Did you look at the store and what data is in it?