Extjs网格分组摘要

时间:2016-03-15 16:15:35

标签: user-interface extjs grid summary

是否可以在不使用组的情况下添加摘要。

var store = Ext.create('Ext.data.Store', {
    model: 'Task',
    groupField: 'reportType',
    proxy: new Ext.data.HttpProxy({
        url: 'getdata.php',
        actionmethods: {read: 'POST'},
        reader: {type: 'json', root:'data'}
    }),
    autoLoad: true
});

var showSummary = true;
var grid = Ext.create('Ext.grid.Panel', {
    height: 450,
    frame: true,
    id: 'test',
    iconCls: 'icon-grid',
    renderTo: document.body,
    store: store,
    features: [{
        id: 'group',
        ftype: 'groupingsummary',
        groupHeaderTpl: '{name}',
        hideGroupedHeader: true,
        enableGroupingMenu: true
    }],
    columns: [{
        text: '',
        width: 120,
        tdCls: 'task',
        sortable: true,
        dataIndex: 'oppdesc',
        hideable: false,
        summaryType: 'count',
        summaryRenderer: function(value, summaryData, dataIndex) {
            return 'In-Period RR';
        }
    }, {
        header: 'W1',
        flex: 1,
        sortable: true,
        dataIndex: 'week1',
        renderer : Ext.util.Format.usMoney,
        summaryType: function(records){
            var counter= 1;
            var data1;
            var data2;

            Ext.Array.forEach(records, function (record){
                if(counter ==1){
                    data1 = record.data.week1;
                }
                else {
                    data2 = record.data.week1;
                }
                counter++;
            });

            var summary = (data2/data1) * 100;
            return summary;

        }]
});

当未设置存储中的groupField配置时,列的摘要似乎不会出现。 当未设置存储中的groupField配置时,列的摘要似乎不会出现。

谢谢!

1 个答案:

答案 0 :(得分:1)

ftype: 'groupingsummary'更改为ftype: 'summary'