▦K2 Advanced GridsDeveloper Portal / 0.23
Documentation / Data presentation

Cell merging

Reduce repetitive values in a standard K2 List View by visually combining consecutive cells, while keeping every purchase order as a separate underlying record.

Before you begin

Use the 17-column Purchase Orders List from the previous lessons. The examples keep nine visible columns, Data Visualization, Boolean icons, filtering, Summary and pagination. For repeatable setup the downloads disable preferences; existing preferences are not deleted. Sort Department ascending for the first examples. For a clear hierarchical result, arrange records in Department and then Vendor order (where available from the source). Merging itself does not sort records.

Download single configuration ↓
Required after saving a configuration file

Replace REPLACE_WITH_YOUR_AREAITEMID with your own ID (see Grid Discovery). Save as the configuration filename loaded by the Data Label, increment configVersion and reload the form. The engine is unchanged.

Before and after

Repeated department values before merging
Figure 079 · Repeated department values before merging · Actual K2 Runtime capture
K2AdvancedGridsConfig.defaults.cellMerging = {
  "enabled": true,
  "columns": [
    "Department"
  ],
  "hierarchical": true,
  "mergeEmpty": false,
  "verticalAlignment": "center",
  "horizontalAlignment": "center",
  "showGroupBorders": true,
  "background": "#f0f4f8",
  "borderColor": "#cbd5e1"
};
K2AdvancedGrids.instance.refresh();
Department merging with active filters
Figure 080 · Department merging with active filters · Actual K2 Runtime capture

Alignment

Choose start, center or end horizontally and top, center or bottom vertically.

K2AdvancedGridsConfig.defaults.cellMerging = {
  "enabled": true,
  "columns": [
    "Department"
  ],
  "hierarchical": true,
  "mergeEmpty": false,
  "verticalAlignment": "top",
  "horizontalAlignment": "start",
  "showGroupBorders": true,
  "background": "#f0f4f8",
  "borderColor": "#cbd5e1"
};
K2AdvancedGrids.instance.refresh();
Top and start alignment
Figure 081 · Top and start alignment · Actual K2 Runtime capture

Hierarchical versus independent merging

Hierarchical mode uses the complete prefix of configured columns as the matching key. Independent mode uses each column separately. Neither mode creates a group header or changes the row count.

Hierarchical

DepartmentVendorOrder
FinanceVendor APO-001
PO-002
HRVendor BPO-003
PO-004
Download hierarchical configuration ↓
K2AdvancedGridsConfig.defaults.cellMerging = {
  "enabled": true,
  "columns": [
    "Department",
    "Vendor Name"
  ],
  "hierarchical": true,
  "mergeEmpty": false,
  "verticalAlignment": "center",
  "horizontalAlignment": "center",
  "showGroupBorders": true,
  "background": "#f0f4f8",
  "borderColor": "#cbd5e1"
};
K2AdvancedGrids.instance.refresh();
Nested Department and Vendor cells
Figure 082 · Nested Department and Vendor cells · Actual K2 Runtime capture

Independent

Sort Vendor Name ascending to see a vendor span different departments.

DepartmentVendorOrder
FinanceVendor APO-001
PO-002
HRPO-003
PO-004
Download independent configuration ↓
K2AdvancedGridsConfig.defaults.cellMerging = {
  "enabled": true,
  "columns": [
    "Department",
    "Vendor Name"
  ],
  "hierarchical": false,
  "mergeEmpty": false,
  "verticalAlignment": "center",
  "horizontalAlignment": "center",
  "showGroupBorders": true,
  "background": "#f0f4f8",
  "borderColor": "#cbd5e1"
};
K2AdvancedGrids.instance.refresh();
Vendor spans separate departments
Figure 083 · Vendor spans separate departments · Actual K2 Runtime capture

Custom styling

Download custom configuration ↓
K2AdvancedGridsConfig.defaults.cellMerging = {
  "enabled": true,
  "columns": [
    "Department",
    "Vendor Name"
  ],
  "hierarchical": false,
  "mergeEmpty": false,
  "verticalAlignment": "center",
  "horizontalAlignment": "center",
  "showGroupBorders": true,
  "background": "#f1e8fb",
  "borderColor": "#c4a5ff"
};
K2AdvancedGrids.instance.refresh();
Custom lavender background and border
Figure 084 · Custom lavender background and border · Actual K2 Runtime capture

Configuration reference

ParameterMeaning
enabledtrue enables merging
columnsOrdered array of column titles or matching identifiers
hierarchicalfalse uses independent keys; otherwise prefix keys
mergeEmptytrue allows empty values to participate
verticalAlignmenttop / center / bottom; center fallback
horizontalAlignmentstart / center / end; center fallback
backgroundCSS color or auto / theme fallback
borderColorCSS color or auto / theme fallback
showGroupBordersfalse removes group borders

Diagnostics and reset

(()=>{const id='REPLACE_WITH_YOUR_AREAITEMID';
const grid=K2AdvancedGrids.instance.inspect().find(g=>g.id===id);
console.table(grid?.cellMerging || []);})();
Diagnostic counts of merged runs and participating rows
Figure 089 · Diagnostic counts of merged runs and participating rows · Actual K2 Runtime capture
K2AdvancedGridsConfig.defaults.cellMerging.enabled = false;
K2AdvancedGrids.instance.refresh();

Benefits and current limitations

Compared with repeating labels in a native List View, merging reduces visual noise and makes adjacent records easier to compare. The engine retains underlying cells and record identities. Merging is restricted to visible rows on the current page, consecutive equal raw values, and simple text cells; Boolean icons, conditional badges and Data Visualization cells are excluded from merging themselves, but may coexist in other columns. Active Row Grouping suppresses merging. Filtering, paging and layout changes trigger recalculation. A group spanning pages is rendered separately on each page. This is not a physical HTML rowspan or a data transformation. The diagrams above are conceptual; screenshots are real Runtime captures.

Enlarged screenshot