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
Configs
11Other
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
bubbleEventsEvents
callOnFunctionsEvents
clientInstancePlugin
localeClassLocalizable
localizableLocalizable
localizablePropertiesLocalizable
Properties
17
Properties
17Common
disabledInstancePlugin
Class hierarchy
Identifies an object as an instance of Summary class, or subclass thereof.
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
Functions
29
Functions
29Other
Refreshes the summaries
addListenerEvents
hasListenerEvents
onEvents
relayAllEvents
removeAllListenersEvents
removeListenerEvents
resumeEventsEvents
suspendEventsEvents
triggerEvents
unEvents
Configuration
Events
detachListenersBase
Misc
animatePropertyBase
callbackBase
doDisableInstancePlugin
downloadTestCaseBase
resolveCallbackBase
updateLocalizationLocalizable
Events
5
Events
5Event handlers
5
Event handlers
5Typedefs
2
Typedefs
2| Parameter | Type | Description |
|---|---|---|
sum | sum | add | count | countNotEmpty | average | function | Summary type, see sum for details |
renderer | function | Renderer function for summary, see summaryRenderer for details |
seed | * | Initial value when using a function as |
BryntumListenerConfigEvents