I’ve created a datagrid using a HttpProxy but it won’t load my data.
I’ve verified that it actually does the request with FireBug but the
data won’t load. No errors, no nothing.
My JS code:
Ext.onReady(function() {
var proxy = new Ext.data.HttpProxy( {
url : '../connectors/testcomponent/ajax.php?action=grid'
});
// Define the reader
var reader = new Ext.data.JsonReader( {
totalProperty: 'total',
root: 'results',
id: 'id'
});
// Build a Store
var store = new Ext.data.Store( {
proxy : proxy,
reader : reader
});
// Load
store.load();
// create the grid
var grid = new Ext.grid.GridPanel( {
store : store,
columns : [ {
header : "Name",
width : 120,
dataIndex : 'name',
sortable : true
}, {
header : "Occupation",
width : 120,
dataIndex : 'occupation',
sortable : true
}],
renderTo : 'mygrid',
width : 540,
height : 200
});
});
The response:
{ 'total': 2, 'results': [ { 'id': 1, 'name': 'Test', occupation: 'test 2' }, { 'id': 2, 'name': 'test 4', occupation: 'test 5' } ] }