2
我在網格中使用'groupingsummary'功能。我試圖從summaryrenderer訪問{name}。如何在ExtJS Grid中的summaryRenderer中使用組名稱
有什麼辦法來訪問(名稱)內summaryrender
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){
// Should return : Math Total:/Science Total:like this.
return Ext.String.format('{0} student{1}', value, value !== 1 ? 's' : '');
}
}, {
dataIndex: 'mark',
text: 'Mark',
summaryType: 'average'
}]
});
像這樣:
感謝您的幫助!
我用 summaryType:function(records){ var myGroupName = records [0] .get('subject'); return myGroupName +'Totals:'; \t \t \t} – aswininayak