PDA

View Full Version : Adding summary grid feature causes it to be added to all grouped items



dustyfrog
19 Aug 2013, 5:19 AM
I have written my own grid feature which supports moving the summary into grouper of the grouped rows. Now this all works fine but when I now try to combine it with the Summary-feature to get a summary of all values on the bottom of the grid. It's failing. For some reason I am getting the summary for all grouped rows instead of only at the bottom. No matter if I use my own feature or the default Grouping feature.

How can I solve this problem?

tobiu
19 Aug 2013, 10:18 AM
We have 2 different summary features for the grid:

the default (total) summary:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.grid.feature.Summary

and the grouping summary:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.grid.feature.GroupingSummary

As far as I know they can be combined.

Without knowing what you did it is not possible for me to tell you what is happening in your scenario. A short testcase could help.

dustyfrog
20 Aug 2013, 12:12 AM
Let me try to reproduce the problem. It's quite simple I want to have grouping and a summary after the last grouped row which displays the sum of all rows within the grid. Like Summary feature is suggested to work but it doesn't.

dustyfrog
20 Aug 2013, 12:19 AM
Okay. I have reproduced the problem. I am using 4.1.2.

Actual result:
A summary row is shown below each grouped rows section in the grid.

Expected result:
A summary row at the bottom of the grid with the sum of the summary columns in the grid.

In my opinion the current behaviour of the Summary-feature is correct based on the documentation. As the documentation suggest it should only display a row on the bottom of the grid.



/*global Ext:false */
Ext.onReady(function () {
var store = Ext.create('Ext.data.Store', {
storeId: 'employeeStore',
fields: ['name', 'seniority', 'department'],
groupField: 'department',
data: {
'employees': [{
"name": "Michael Scott",
"seniority": 7,
"department": "Management"
}, {
"name": "Dwight Schrute",
"seniority": 2,
"department": "Sales"
}, {
"name": "Jim Halpert",
"seniority": 3,
"department": "Sales"
}, {
"name": "Kevin Malone",
"seniority": 4,
"department": "Accounting"
}, {
"name": "Angela Martin",
"seniority": 5,
"department": "Accounting"
}]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'employees'
}
}
});


Ext.create('Ext.grid.Panel', {
title: 'Employees',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Seniority',
dataIndex: 'seniority',
summaryType: 'sum'
}],
features: [{
ftype: 'grouping'
},
{
ftype:'summary'
}],
width: 200,
height: 275,
renderTo: Ext.getBody()
});
});

dustyfrog
9 Sep 2013, 2:53 AM
Sad thought I haven't received any response yet. In the meantime I have just wrote my own feature which merge both features to get the expected result. Silly that this needs to be done.