How to do Ext.grid.feature.GroupingSummary by multiple fields?
Code:
Ext.define('TestResult', {
extend: 'Ext.data.Model',
fields: ['student', 'subject', {
name: 'mark',
type: 'int'
}]
});
Ext.create('Ext.grid.Panel', {
width: 200,
height: 240,
renderTo: document.body,
features: [{
groupHeaderTpl: 'Subject: {name}',
ftype: 'groupingsummary'
}],
store: {
model: 'TestResult',
groupField: 'subject',
data: [{
student: 'Student 1',
subject: 'Math',
mark: 84
},{
student: 'Student 1',
subject: 'Science',
mark: 72
},{
student: 'Student 2',
subject: 'Math',
mark: 96
},{
student: 'Student 2',
subject: 'Science',
mark: 68
}]
},
columns: [{
dataIndex: 'student',
text: 'Name',
summaryType: 'count',
summaryRenderer: function(value){
return Ext.String.format('{0} student{1}', value, value !== 1 ? 's' : '');
}
}, {
dataIndex: 'mark',
text: 'Mark',
summaryType: 'average'
}]
});
In this above example i want to group by multiple fields .like this
groupField: ['subject', 'student']
Is this possible ? can u guys helped me how to achieve that ?
how to display newly defined 'surname' in grouping header?
hi,
surname kind of grouping works fine. Now I am facing to an issue to display it, or similar in grouping header.
In my case grouping members by projects, as "team"
return instance.get(group.property)+ ', ' + instance.get('member').fullName + '(' + instance.get('project').description + ')';
"team" in header:
groupHeaderTpl: ' Team: {team} ({rows.length})',
the problem for me the nested objects and to read value in the header template. Somehow member.fullName does not work.
thx,
Zol