PDA

View Full Version : can't startup a simple grid



gruu
18 Feb 2008, 6:50 AM
why is the grid allways empty? wht's wrong?


Ext.onReady(function() {
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'dades.php'}),
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'totalCount',
id: 'id',
fields:['company','companyID']
})
});


var colModel = new Ext.grid.ColumnModel([
{header: "Company", width: 120, sortable: true, dataIndex:'company'},
{header: "ID", width: 90, sortable: true, dataIndex:'companyID'}
]);

var grid = new Ext.grid.GridPanel({ds:ds,cm:colModel});
grid.render("gridDiv");
ds.load({params:{start:0, limit:25}});
});


the response form "dades.php":
({"totalCount":"2","results":[{"companyID":"1","company":"Alcoa34"},{"companyID":"2","company":"General Electric Company"},]})

gruu
18 Feb 2008, 7:24 AM
argh.. can anyone move this post to ext 2.0 help?

cerad
18 Feb 2008, 7:51 AM
Think you might need an id attribute here:
{id: 'companyID', header: "ID", width: 90, ...

Grids need a way to uniquely identify each row.

gruu
18 Feb 2008, 11:32 AM
it's needed to specify the height.

var grid = new Ext.grid.GridPanel({ds:ds,cm:colMode,height:300});