REQUIRED INFORMATION




Ext version tested:
  • Ext 4.2.1 rev aed16176e68b5e8aa1433452b12805c0ad913836
Browser versions tested against:
  • Any
DOCTYPE tested against:
  • Any
Description:
  • Summary feature doesn't work with TreePanel, because TreeStore doesn't have model property
Steps to reproduce the problem:
  • Create TreeModel
  • Create TreeStore
  • Create TreePanel
  • Add ftype summary to the TreePanel
The result that was expected:
  • Should works as in simple grid
The result that occurs instead:
  • There is an exception in the console about creating object from nothing
Solution:

Code:
Ext.define('Ext.tree.feature.Summary', {
    extend: 'Ext.grid.feature.Summary',
    alias: 'feature.treesummary',
    createSummaryRecord: function(view) {
        var columns = view.headerCt.getVisibleGridColumns(),
            info = {
                records: view.store.getRange()
            },
            colCount = columns.length, i, column,
            summaryRecord = this.summaryRecord || (this.summaryRecord = new view.store.treeStore.model(null, view.id + '-summary-record'));


            summaryRecord.beginEdit();
            for(i = 0; i < colCount; ++i) {
                column = columns[i];
                if(!column.dataIndex) {
                    column.dataIndex = column.id;
                }
                if(this.remoteRoot) {
                    column.summaryType = 'remote';
                }
                summaryRecord.set(column.dataIndex, this.getSummary(view.store.treeStore, column.summaryType, column.dataIndex, info));
            }
            summaryRecord.endEdit(true);
            summaryRecord.commit(true);
            summaryRecord.isSummary = true;
            return summaryRecord;
    }
});