I'm having the same problem...what am I doing wrong?
This is my JSON data source:
Code:
{"totalCount":12,"dailyGroupTotals":[{"date":"2012-02-20","group_name":"Grocery","total_group":"8769.17"},{"date":"2012-02-20","group_name":"Meat","total_group":"8201.26"},{"date":"2012-02-20","group_name":"Produce","total_group":"1885.69"},{"date":"2012-02-21","group_name":"Grocery","total_group":"7648.46"},{"date":"2012-02-21","group_name":"Meat","total_group":"6359.98"},{"date":"2012-02-21","group_name":"Produce","total_group":"1651.09"},{"date":"2012-02-22","group_name":"Grocery","total_group":"7122.25"},{"date":"2012-02-22","group_name":"Meat","total_group":"5957.75"},{"date":"2012-02-22","group_name":"Produce","total_group":"1533.25"},{"date":"2012-02-23","group_name":"Grocery","total_group":"343.29"},{"date":"2012-02-23","group_name":"Meat","total_group":"235.11"},{"date":"2012-02-23","group_name":"Produce","total_group":"132.64"}]}
This is my rendering code:
Code:
Ext.require([ 'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.state.*'
]);
Ext.onReady(function() {
Ext.QuickTips.init();
// setup the state provider, all state information will be saved to a cookie
Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
// create the data model
Ext.define('Group', {
extend: 'Ext.data.Model',
fields: [
{name: 'date', type: 'date'},
{name: 'group_name', type: 'string'},
{name: 'total_group', type: 'float'},
],
});
// create the data store
var store = Ext.create('Ext.data.Store', {
model: 'Group',
proxy: {
type: 'ajax',
url : '/select6.php',
reader: {
type: 'json',
root: 'dailyGroupTotals'
}
},
autoLoad: true
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
stateId: 'stateGrid',
columns: [
{
text : 'Date',
width : 100,
sortable : true,
//renderer : Ext.util.Format.dateRenderer('m-d'),
dataIndex: 'date'
},
{
text : 'Group',
width : 100,
sortable : true,
dataIndex: 'group_name'
},
{
text : 'Total',
width : 150,
sortable : true,
renderer : 'usMoney',
align: 'right',
dataIndex: 'total_group'
},
],
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
}
});
});
This is the resulting grid:
grid.png