我已经创建了 Ext.grid.Panel,现在我需要对在服务器上计算的数据进行汇总。而且我在那个网格中没有分组。
在功能ftype: 'summary'
中没有像“remoteRoot”这样的属性。有没有机会在不分组的情况下创建此摘要?
我已经创建了 Ext.grid.Panel,现在我需要对在服务器上计算的数据进行汇总。而且我在那个网格中没有分组。
在功能ftype: 'summary'
中没有像“remoteRoot”这样的属性。有没有机会在不分组的情况下创建此摘要?
您必须扩展/覆盖类。这是一个基于 AbstractSummary.js 的示例,应该进行优化。
// usage in grid:
{
ftype : 'summary',
remoteRoot : 'summary'
}
//response from server
{
data : [] // our standard data
summary : {
summaryField : 123123
}
}
// our class
Ext.define('w3desApp.grid.feature.Summary', {
override : 'Ext.grid.feature.Summary',
getSummary: function(store, type, field, group) {
var reader = store.proxy.reader;
if (this.remoteRoot && reader.rawData) {
// reset reader root and rebuild extractors to extract summaries data
root = reader.root;
reader.root = this.remoteRoot;
reader.buildExtractors(true);
summaryRow = reader.getRoot(reader.rawData);
// restore initial reader configuration
reader.root = root;
reader.buildExtractors(true);
if (typeof summaryRow[field] != 'undefined') {
return summaryRow[field];
}
return '';
}
return this.callParent(arguments);
}
});