Skip to content

Same Value Merge

ColumnRegular (Extended from @revolist/revogrid)

Section titled “ColumnRegular (Extended from @revolist/revogrid)”
interface ColumnRegular {
/**
* Enables same-value merging for this column.
*
* `true` keeps the legacy behavior: adjacent comparable rows merge when
* this column's value matches. Object config enables grouped merge
* boundaries where follower columns inherit a leader column's row run.
*/
merge?: boolean | SameValueMergeConfig
}
export type SameValueMergeConfig = {
/**
* Shared identifier for columns that should use the same merge boundaries.
* Columns in the same group look for a column with `mergeLeader: true`.
*/
mergeGroup?: string;
/**
* Marks this column as the boundary source for its `mergeGroup`.
* Follower columns still compare their own values, but cannot merge beyond
* the leader column's comparable row run.
*/
mergeLeader?: boolean;
/**
* Additional row fields that must match before this column can merge.
* This is most useful on the merge leader to split equal leader values by
* business keys such as material, operation number, or route id.
*/
mergeDependsOn?: ColumnProp[];
/**
* Marks merge-run start cells as sticky through StickyCellsPlugin.
*
* SameValueMergePlugin auto-registers StickyCellsPlugin when this option is
* enabled on at least one merge column.
*/
sticky?: boolean;
};

The SameValueMergePlugin is a RevoGrid plugin designed to merge cells with the same values in a column. It adds visual merge markers to cells that have the same value as the nearest comparable visible row above or below them.

Key Features:

  • Visible row comparison: Checks nearest comparable visible rows above and below the current cell
  • Grouping support: Group rows are comparable when they carry the current column value
  • Column Configuration: Supports a ‘merge’ property on columns to enable/disable merging
  • Grouped boundaries: Columns can share a mergeGroup and follow a mergeLeader run
  • Visual Styling: Adds an auto-merge marker used by CSS to hide repeated values

Usage:

  • This plugin should be included in the grid’s plugin array to enable same-value merging functionality.
  • Configure columns with the ‘merge’ property to enable merging for specific columns.
import { SameValueMergePlugin } from './same-value-merge-plugin';
const grid = document.createElement('revo-grid');
grid.plugins = [SameValueMergePlugin]; // Add merge plugin
grid.columns = [
{ prop: 'name', name: 'Name' },
{ prop: 'category', name: 'Category', merge: true }, // Enable merging for this column
];
grid.columns = [
{ prop: 'material', name: 'Material' },
{ prop: 'operationNo', name: 'Operation' },
{
prop: 'workcenter',
name: 'Work Center',
merge: {
mergeGroup: 'operation',
mergeLeader: true,
mergeDependsOn: ['material', 'operationNo'],
},
},
{ prop: 'quantity', name: 'Quantity', merge: { mergeGroup: 'operation' } },
];
class SameValueMergePlugin {
destroy(): void;
}

export function isSameValueMergeConfig(merge: ColumnRegular['merge']): merge is SameValueMergeConfig;

export function getMergeConfig(column: ColumnRegular | undefined): SameValueMergeConfig | undefined;

export function isMergeEnabled(column: ColumnRegular | undefined): column is ColumnRegular;

export function resolveSameValueMergeState(;

export type MergeCellState = {
autoMerge: 'main' | 'child' | 'last';
endsBeforeGroup: boolean;
};

export function applySameValueMergeStickyColumns(
columnsByType: ColumnCollection['columns'],
resolveMergeStickyCell: (
model: CellTemplateProp,
stickyCell: StickyCellPredicate | undefined,
) => boolean,
): boolean;

export function isPivotGeneratedRow(model?: DataType);

export function isPivotTotalRow(model?: DataType);

export function hasPivotMergeBoundary(
items: number[],
visibleIndex: number,
source: DataType[],
currentModel: DataType | undefined,
prop: ColumnProp,
);