I'm a newbie to extjs and so far it looks great. I'm trying to integrate it with PHP but having some issues. The grid is defined as below and it tries to use a jsonreader to load data from the database
PHP Code:
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'dataload.php'
}),
reader: new Ext.data.JsonReader({
root: 'countries'
}, [
{name: 'id'},
{name: 'code'},
{name: 'country'}
]),
remoteSort: true
});
ds.setDefaultSort('id', 'desc');
var countrygrid = new Ext.grid.GridPanel({
store: ds,
columns: [
{id:'id', header: "id", width: 200, sortable: true, dataIndex: 'id'},
{header: "Code", width: 120, sortable: true, dataIndex: 'code'},
{header: "Country", width: 120, sortable: true, dataIndex: 'country'}
],
viewConfig: {
forceFit: true
},
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
width:600,
height:300,
frame:true,
title:'Countries',
iconCls:'icon-grid'
});
countrygrid.render('country-grid');
countrygrid.getSelectionModel().selectFirstRow();
ds.loadData();
the dataload.php file simply selects countries from the database and encodes it as follows
PHP Code:
$jsonEncodedCountries = json_encode($arr);
header('Content-Type', 'text/javascript');
echo $jsonEncodedCountries;
Even after doing this i do not see the data displayed in the grid? Please let me know what i'm missing