▦K2 Advanced GridsDeveloper Portal / 0.24
Documentation / Data management

Aggregation & Summary

Turn your register into an analytical view using client-side metrics, KPI cards and column-aligned totals.

Overview and prerequisites

Continue from Pagination & Load More. Keep nine columns, filtering and classic pagination enabled. Aggregates use the records already loaded into the browser; no additional SQL query is required.

Quick start — KPI cards

Replace the aggregation section under defaults with this fragment. For a complete configuration, replace REPLACE_WITH_YOUR_AREAITEMID with your own ID (see Grid Discovery), then save as purchase-orders.config.js or update the loader filename.

"aggregation": {
    "enabled": true,
    "scope": "filtered",
    "position": "top",
    "layout": "kpi",
    "alignment": "start",
    "showTitle": false,
    "showScope": true,
    "showLabels": true,
    "showSeparators": false,
    "items": [
        {
            "operation": "count",
            "label": "Total Orders"
        },
        {
            "column": "Order Amount",
            "operation": "sum",
            "label": "Total Order Value",
            "precision": 2
        },
        {
            "column": "Order Amount",
            "operation": "avg",
            "label": "Average Order Value",
            "precision": 2
        },
        {
            "column": "Budget Variance",
            "operation": "sum",
            "label": "Total Budget Variance",
            "precision": 2
        }
    ]
}
Download KPI configuration ↓
Required after saving a configuration file

Update configVersion in the Data Label loader (for example from 0.3.0 to 0.4.0), save the form and reopen Runtime. Keep engineVersion unchanged unless the engine file was modified. Console-only experiments do not need a version change. See Installation & Deployment.

KPI cards above the toolbar — 250 orders
Figure 21 · KPI cards above the toolbar — 250 orders · Actual K2 Runtime capture

Dynamic filtering

Apply Status = Pending Approval and Budget Variance greater than 0. The four KPIs recalculate for 14 matching orders even though only ten are displayed.

Filtered KPIs — 14 matching orders
Figure 22 · Filtered KPIs — 14 matching orders · Actual K2 Runtime capture

Aggregation scope

Keep the same filters. Switch between loaded, filtered and page scopes using the following Console command. These examples change shared defaults; an individual grid override can take precedence.

K2AdvancedGridsConfig.defaults.aggregation.scope = 'loaded';
K2AdvancedGrids.instance.refresh();
Loaded scope — all 250 orders despite active filters
Figure 23 · Loaded scope — all 250 orders despite active filters · Actual K2 Runtime capture
K2AdvancedGridsConfig.defaults.aggregation.scope = 'page';
K2AdvancedGrids.instance.refresh();
Page scope — first ten matching orders
Figure 24 · Page scope — first ten matching orders · Actual K2 Runtime capture
Page scope — four remaining orders on page two
Figure 25 · Page scope — four remaining orders on page two · Actual K2 Runtime capture
Interactive scope example

Choose a scope to compare the actual captured metrics. This is an offline simulation, not a live K2 grid.

MetricLoadedFilteredPage 1Page 2
Count25014104
Sum29,401,126.091,972,616.041,292,840.03679,776.01
Average117,604.50140,901.15129,284.00169,944.00
Variance3,745.0013,909.7011,099.102,810.60

Compact summary

Clear the filters. Use a compact strip beneath the records or above the column headers.

Object.assign(K2AdvancedGridsConfig.defaults.aggregation, {
    "scope": "filtered",
    "layout": "compact",
    "position": "bottom",
    "alignment": "end",
    "showTitle": true,
    "showScope": true,
    "showLabels": true,
    "showSeparators": true
});
K2AdvancedGrids.instance.refresh();
Download Compact configuration ↓
Compact summary — bottom, aligned to the end
Figure 26 · Compact summary — bottom, aligned to the end · Actual K2 Runtime capture
K2AdvancedGridsConfig.defaults.aggregation.position = 'top';
K2AdvancedGrids.instance.refresh();
Compact summary — top
Figure 27 · Compact summary — top · Actual K2 Runtime capture

Column-aligned summary

Specify a column for each metric. Multiple metrics can occupy one column; the count is explicitly associated with Order Number.

Object.assign(K2AdvancedGridsConfig.defaults.aggregation, {
    "enabled": true,
    "scope": "filtered",
    "position": "bottom",
    "layout": "columns",
    "alignment": "end",
    "showTitle": false,
    "showScope": false,
    "showLabels": true,
    "showSeparators": true,
    "items": [
        {
            "column": "Order Number",
            "operation": "count",
            "label": "Count"
        },
        {
            "column": "Order Amount",
            "operation": "sum",
            "label": "Sum",
            "precision": 2
        },
        {
            "column": "Order Amount",
            "operation": "avg",
            "label": "Average",
            "precision": 2
        },
        {
            "column": "Budget Variance",
            "operation": "sum",
            "label": "Sum",
            "precision": 2
        }
    ]
});
K2AdvancedGrids.instance.refresh();
Download Columns configuration ↓
Column-aligned summary — bottom
Figure 28 · Column-aligned summary — bottom · Actual K2 Runtime capture
K2AdvancedGridsConfig.defaults.aggregation.position = 'top';
K2AdvancedGrids.instance.refresh();
Column-aligned summary — top
Figure 29 · Column-aligned summary — top · Actual K2 Runtime capture

Additional operations

Object.assign(K2AdvancedGridsConfig.defaults.aggregation, {
    "enabled": true,
    "scope": "filtered",
    "position": "top",
    "layout": "kpi",
    "alignment": "end",
    "showTitle": false,
    "showScope": true,
    "showLabels": true,
    "showSeparators": false,
    "items": [
        {
            "operation": "count",
            "label": "Total Orders"
        },
        {
            "column": "Vendor Name",
            "operation": "countDistinct",
            "label": "Unique Vendors"
        },
        {
            "column": "Order Amount",
            "operation": "min",
            "label": "Lowest Order Value",
            "precision": 2
        },
        {
            "column": "Order Amount",
            "operation": "max",
            "label": "Highest Order Value",
            "precision": 2
        }
    ]
});
K2AdvancedGrids.instance.refresh();
Count, distinct vendors, minimum and maximum order value
Figure 30 · Count, distinct vendors, minimum and maximum order value · Actual K2 Runtime capture

Configuration reference

ParameterType / allowed valuesBehavior
enabledBoolean; true enablesOtherwise summary is disabled
scopeloaded / filtered / pageLoaded rows, matching rows, or displayed page; fallback filtered
positiontop / bottomFallback bottom
layoutkpi / compact / columnsFallback compact; cards use compact instead of columns
alignmentstart / center / endFallback end
showTitleBooleanOnly true shows Summary
showScopeBooleanOnly true shows scope label
showLabelsBooleanShown unless false
showSeparatorsBooleanEnabled only when true
itemsArrayMetric definitions
items[].columnStringColumn key, name or title; omit for record count
items[].operationcount / countDistinct / sum / avg / min / maxDefaults to count
items[].labelStringOptional custom metric label
items[].precisionInteger 0–12Decimal and average default 2; other numeric operations default 0
items[].prefix / suffixStringOptional display text
items[].fontWeight400 / 500 / 600 / 700 / 800Fallback 600
OperationMeaning
countRows if no column is specified; otherwise nonblank values
countDistinctDistinct nonblank values
sumSum of numeric values
avgArithmetic mean of valid numeric values
minLowest numeric value
maxHighest numeric value

Standard vs Advanced

Unlike a plain ListView in our baseline, the same register now offers live aggregates, three presentation layouts and a selectable calculation scope without creating a separate summary View.

Limitations and troubleshooting

  • Totals cover only loaded records, not necessarily every record in SQL.
  • Numeric operations require a numeric column; blank values are ignored. No valid numeric values display an em dash.
  • Use a column reference for column-aligned metrics. Check exact header names or keys if a metric is missing.
  • Console changes are temporary. Reopen the form to restore the saved configuration.
  • Amounts shown in the screenshots are rounded for display; totals use underlying numeric values.
Required after saving a configuration file

Update configVersion in the Data Label loader (for example from 0.3.0 to 0.4.0), save the form and reopen Runtime. Keep engineVersion unchanged unless the engine file was modified. Console-only experiments do not need a version change. See Installation & Deployment.

Next step

Restore the KPI configuration and continue with Horizontal & vertical scrolling.

Enlarged screenshot