getSummary()
returns an object with the specified calculated values
Usage
interface ISummaryList {
[key: string]: string | number | null;
}
getSummary(colId?: string | number): ISummaryList;
Parameters:
colId?: string | number
- optional, the id of a column
Returns:
An object with the list of calculated values
Example
const grid = new dhx.Grid("grid_container", {
columns: [
{ width: 150, id: "population", header: [{ text: "Population" }] },
{
width: 150,
id: "age",
header: [{ text: "Med. Age" }],
summary: { avgAge: "avg" }
}
],
summary: {
totalPopulation: ["population", "sum"],
},
data: dataset
});
// getting summary data for the component
const totalSummary = grid.getSummary();
console.log(totalSummary); //{ totalPopulation: 1000000 } - the sum of all the values in the "population" column
// getting summary data for a column
const columnSummary = grid.getSummary("age");
console.log(columnSummary); //{ totalPopulation: 1000000, avgAge: 28 } - the value of the "age" column only
- When called without parameters, the method returns an object with the calculated values defined in the configuration of the component.
- When the
id
parameter is passed to the method, it returns an object with the calculated values defined in the column's configuration together with the calculated values defined in the component's configuration.
Related article: Getting the summary object
Related: summary
Change log:
- Added in v9.0