Handle this as example how you could implement.
This is how it looks like(of course it will be different data but you see the point):
![enter image description here](https://i.stack.imgur.com/VVTsQ.png)
Lets see example of json(how it could be and how i understand your problem):
{
"stats":[
{
"name":"Amount summary",
"value":"2300"
},
{
"name":"Mortgage",
"value":"1100"
}
],
"success":true,
"totalCount":2,
"items":[
{
"Amount":"1000",
"Delta":"3",
"Mortgage":"500"
},{
"Amount":"1300",
"Delta":"4",
"Mortgage":"600"
}
]
}
Model:
Ext.define('Application.model.MyModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'Amount',
type: 'string'
},{
name: 'Delta',
type: 'string'
},{
name: 'Mortgage',
type: 'string'
}]
});
Store:
var writer = new Ext.data.JsonWriter({
type: 'json',
encode: false,
listful: true,
writeAllFields: true,
returnJson: true
});
var reader = new Ext.data.JsonReader({
type: 'json',
totalProperty: 'totalCount',
rootProperty: 'items',
successProperty: 'success'
});
var proxy = new Ext.data.HttpProxy({
reader: reader,
writer: writer,
type: 'ajax',
url: 'urlForJson',
headers: {
'Content-Type': 'application/json; charset=UTF-8'
}
});
Ext.define('Application.store.MyStore', {
extend : 'Ext.data.Store',
storeId : 'MyStore',
model : 'Application.model.MyModel',
autoLoad: false,
autoSync: true,
proxy:proxy
});
Lets define controller that is going to handle our summary/statistics:
Ext.define('Application.controller.SummaryController', {
extend: 'Ext.app.Controller',
refs: [
{
selector: 'summaryPanel',
ref: 'summaryPanel'
}
],
init: function () {
var controller = this;
controller.listen({
controller: {
'*': {
addSummary: 'addSummary'
}
}
});
},
/**
* Add summary.
*/
addSummary: function addSummary(summary) {
var controller = this;
var summaryPanel= controller.getSummaryPanel();
summaryPanel.removeAll();
Ext.Object.each(stats, function(property, stat){
var labelFieldName = new Ext.form.Label({
text: stat.name+': '
});
var labelFieldValue = new Ext.form.Label({
text: stat.value+' ',
cls: 'bold-item'
});
summaryPanel.items.add(labelFieldName);
summaryPanel.items.add(labelFieldValue);
});
summaryPanel.up('window').doLayout();
}
});
And this is our SummaryPanel:
Ext.define('Application.view.SummaryPanel', {
extend: 'Ext.Panel',
alias: 'widget.summaryPanel',
xtype: 'summaryPanel',
layout: 'anchor',
bodyStyle: 'padding: 5px 5px;',
items: []
});
In next step we are going to load our data to grid and after that we will fill our SummaryPanel
with statistics/summary:
Ext.define('Application.controller.GridController', {
extend: 'Ext.app.Controller',
init: function () {
var controller = this;
controller.control({
'gridControlPanel': {
'afterrender': function () {
controller.loadStore();
}
}
})
},
loadStore: function () {
var controller = this;
var store = Ext.getStore('Application.store.MyStore');
store.load({
callback: function (records, operation, success) {
var data = Ext.JSON.decode(operation._response.responseText);
if (!Ext.isEmpty(data.stats)) {
//After loading data, make statistics.
controller.fireEvent('addSummary', data.stats);//This event is handled by SummaryController
}
}
});
}
});
And this UI
that cover all above:
Ext.define('Application.view.GridWindow', {
extend: 'Ext.window.Window',
alias: 'widget.gridWindow',
xtype: 'gridWindow',
addMode: false,
autoShow: true,
width: 1200,
height: 700,
resizable: true,
layout: 'fit',
items: [{
xtype: 'grid',
store: 'Application.store.MyStore',
dockedItems: [{
xtype: 'pagingtoolbar',
dock: 'bottom',
store: 'Application.store.MyStore',
displayInfo: true
}]
}],
dockedItems: [{
xtype: 'summaryPanel'//This is our summary panel that will show your summarize.
}]
});