Same Value Merge
Module Extensions
Section titled “Module Extensions”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}Plugin API
Section titled “Plugin API”SameValueMergeConfig
Section titled “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;};SameValueMergePlugin
Section titled “SameValueMergePlugin”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
mergeGroupand follow amergeLeaderrun - Visual Styling: Adds an
auto-mergemarker 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.
Example
Section titled “Example”import { SameValueMergePlugin } from './same-value-merge-plugin';
const grid = document.createElement('revo-grid');grid.plugins = [SameValueMergePlugin]; // Add merge plugingrid.columns = [ { prop: 'name', name: 'Name' }, { prop: 'category', name: 'Category', merge: true }, // Enable merging for this column];Grouped merge example
Section titled “Grouped merge example”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;}isSameValueMergeConfig
Section titled “isSameValueMergeConfig”export function isSameValueMergeConfig(merge: ColumnRegular['merge']): merge is SameValueMergeConfig;getMergeConfig
Section titled “getMergeConfig”export function getMergeConfig(column: ColumnRegular | undefined): SameValueMergeConfig | undefined;isMergeEnabled
Section titled “isMergeEnabled”export function isMergeEnabled(column: ColumnRegular | undefined): column is ColumnRegular;resolveSameValueMergeState
Section titled “resolveSameValueMergeState”export function resolveSameValueMergeState(;MergeCellState
Section titled “MergeCellState”export type MergeCellState = { autoMerge: 'main' | 'child' | 'last'; endsBeforeGroup: boolean;};applySameValueMergeStickyColumns
Section titled “applySameValueMergeStickyColumns”export function applySameValueMergeStickyColumns( columnsByType: ColumnCollection['columns'], resolveMergeStickyCell: ( model: CellTemplateProp, stickyCell: StickyCellPredicate | undefined, ) => boolean,): boolean;isPivotGeneratedRow
Section titled “isPivotGeneratedRow”export function isPivotGeneratedRow(model?: DataType);isPivotTotalRow
Section titled “isPivotTotalRow”export function isPivotTotalRow(model?: DataType);hasPivotMergeBoundary
Section titled “hasPivotMergeBoundary”export function hasPivotMergeBoundary( items: number[], visibleIndex: number, source: DataType[], currentModel: DataType | undefined, prop: ColumnProp,);