Skip to content

Plugin: ColumnSummary

Description

The ColumnSummary plugin lets you easily summarize your columns.

You can use the built-in summary functions, or implement a custom summary function.

For each column summary, you can set the following configuration options:

OptionRequiredTypeDefaultDescription
sourceColumnNoNumberSame as destinationColumnSelects a column to summarize
rangesNoArray-Selects ranges of rows to summarize
typeYesString-Sets a summary function
destinationRowYesNumber-Sets the destination cell’s row coordinate
destinationColumnYesNumber-Sets the destination cell’s column coordinate
forceNumericNoBooleanfalseForces the summary to treat non-numerics as numerics
reversedRowCoordsNoBooleanfalseReverses the row coordinate, count row coordinates backward. Useful when displaying summary results at the bottom of the grid, as it allows you to reference rows relative to the last row (e.g., destinationRow: 0 refers to the last row when this option is enabled)
suppressDataTypeErrorsNoBooleantrueSuppresses data type errors
readOnlyNoBooleantrueMakes summary cell read-only
roundFloatNoNumber/
Boolean
-Rounds summary result
customFunctionNoFunction-Lets you add a custom summary function

Example

<HotTable
data={getData()}
colHeaders={true}
rowHeaders={true}
columnSummary={[
{
type: 'min',
destinationRow: 4,
destinationColumn: 1,
},
{
type: 'max',
destinationRow: 0,
destinationColumn: 3,
reversedRowCoords: true
},
{
type: 'sum',
destinationRow: 4,
destinationColumn: 5,
forceNumeric: true
}
]}
/>

Options

columnSummary

Source code

columnSummary.columnSummary : Array<object> | function

The columnSummary option configures the ColumnSummary plugin.

You can set the columnSummary option to an array of objects. Each object configures a single column summary, using the following properties:

PropertyPossible valuesDescription
sourceColumnA numberColumn to summarize
rangesAn arrayRanges of rows to summarize
type'sum' | 'min' | 'max' | 'count' | 'average' | 'custom'Summary function
destinationRowA numberDestination cell’s row coordinate
destinationColumnA numberDestination cell’s column coordinate
forceNumerictrue | falseTreat non-numerics as numerics
reversedRowCoordstrue | falseReverse row coordinates
suppressDataTypeErrorstrue | falseSuppress data type errors
readOnlytrue | falseMake summary cell read-only
roundFloattrue | false | A numberRound summary result
customFunctionA functionCustom summary function

Read more:

Default: undefined
Example

columnSummary: [
{
sourceColumn: 0,
ranges: [
[0, 2], [4], [6, 8]
],
type: 'custom',
destinationRow: 4,
destinationColumn: 1,
forceNumeric: true,
reversedRowCoords: true,
suppressDataTypeErrors: false,
readOnly: true,
roundFloat: false,
customFunction(endpoint) {
return 100;
}
}
],

Methods

disablePlugin

Source code

columnSummary.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin

Source code

columnSummary.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

isEnabled

Source code

columnSummary.isEnabled() ⇒ boolean

Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit hook and if it returns true then the ColumnSummary#enablePlugin method is called.

updatePlugin

Source code

columnSummary.updatePlugin()

Updates the plugin’s state.

This method is executed when updateSettings() is invoked with any of the following configuration options: