Summary

Displays a summary row in the grid footer.

Summary
//<code-header>
fiddle.title = 'Summary';
//</code-header>
targetElement.innerHTML = '<p>Specify type of summary on a column to have it displayed in the footer</p>';

const grid = new Grid({
    appendTo : targetElement,

    // makes grid as high as it needs to be to fit rows
    autoHeight : true,

    features : {
        // enable summaries
        summary : true
    },

    data : DataGenerator.generateData(5),

    columns : [
        { field : 'name', text : 'Name', flex : 1 },
        { type : 'number', field : 'score', text : 'Score', flex : 1, sum : 'sum' },
        { type : 'number', field : 'rank', text : 'Rank', flex : 1, sum : 'average' }
    ]
});

On each column you can specify the type of sum, available types are:

Type Description
sum Sum of all values in the column
add Alias for sum
count Number of rows
countNotEmpty Number of rows containing a value
average Average of all values in the column
function A custom function, used with store.reduce. Should take arguments (sum, record)

Columns can also specify a summaryRenderer to format the calculated sum.

This feature is disabled by default.

{ text : 'Score', data : 'score', width : 80, sum : 'sum' }
{ text : 'Rank', data : 'rank', width : 80, sum : 'average', summaryRenderer: ({ sum }) => return 'Average rank ' + sum }

Also, it is possible to set up multiple summaries as array of summary configs:

{ text : 'Rank', data : 'rank', summaries : [{ sum : 'average', label : 'Average' }, { sum : 'count', label : 'Count' }] }

When Store has lazyLoad, this feature will only work on locally available data

Configs

11

Common

disabledInstancePlugin
listenersEvents

Other

Set to true to only refresh columns with fields matching the changed fields after a field update

Set to true to sum values of selected row records

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

17

Common

disabledInstancePlugin

Class hierarchy

isSummary: Boolean= truereadonly
Identifies an object as an instance of Summary class, or subclass thereof.
isSummary: Boolean= truereadonlystatic
Identifies an object as an instance of Summary class, or subclass thereof.
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable

Other

Set to true to only refresh columns with fields matching the changed fields after a field update

Set to true to sum values of selected row records

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Functions

29

Other

Refreshes the summaries

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Events

5
catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

5
onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

2
ParameterTypeDescription
sumsum | add | count | countNotEmpty | average | function

Summary type, see sum for details

rendererfunction

Renderer function for summary, see summaryRenderer for details

seed*

Initial value when using a function as sum