PDA

View Full Version : ExtJS JsonStore



ruialexrib
1 Nov 2012, 1:11 PM
i making my first steps with ExtJs and cant figure out whats the problem with this example...
the grid is showing but with no records




Ext.onReady(function () {

var store = new Ext.data.JsonStore({
root: 'results',
autoLoad: true,
fields: ['name'],
data: {
results: [
{ "name": "John Smith" },
{ "name": "Anna Smith" }
]
}
});

var grid = new Ext.grid.GridPanel({
width: 600,
height: 200,
store: store,
columns: [
{
id: 'name',
header: "NAME",
sortable: true,
dataIndex: 'name'
}
],
});

// render grid
grid.render('db-grid');

});

vietits
1 Nov 2012, 2:35 PM
Try to config the store a below:


var store = new Ext.data.JsonStore({
//root: 'results',
//autoLoad: true,
fields: ['name'],
proxy: {
type: 'memory',
reader: {
root: 'results'
}
},
data: {
results: [
{ "name": "John Smith" },
{ "name": "Anna Smith" }
]
}
});

ruialexrib
2 Nov 2012, 3:10 PM
it works... thx =D>