@@ -6,19 +6,34 @@ import { GridType } from '../grids/common/grid.interface';
66export interface IMergeByResult {
77 rowSpan : number ;
88 root ?: any ;
9- prev ?: any ;
109}
1110
11+ /**
12+ * Merge strategy interface.
13+ */
1214export interface IGridMergeStrategy {
1315 /* blazorSuppress */
16+ /**
17+ * Function that processes merging of the whole data per merged field.
18+ * Returns collection where object has reference to the original record and map of the cell merge metadata per field.
19+ */
1420 merge : (
21+ /* The original data to merge. */
1522 data : any [ ] ,
23+ /* The field in the data to merge. */
1624 field : string ,
25+ /* Custom comparer function to use for field. */
1726 comparer : ( prevRecord : any , currentRecord : any , field : string ) => boolean ,
27+ /* Existing merge result to which to add the field specific metadata for merging. */
1828 result : any [ ] ,
19- activeRowIndexes : number [ ] ,
29+ /* The active row indexes, where merging should break the sequence. */
30+ activeRowIndexes : number [ ] ,
31+ /* Optional reference to the grid */
2032 grid ?: GridType
2133 ) => any [ ] ;
34+ /**
35+ * Function that compares values for merging. Returns true if same, false if different.
36+ */
2237 comparer : ( prevRecord : any , record : any , field : string ) => boolean ;
2338}
2439
@@ -35,7 +50,7 @@ export class DefaultMergeStrategy implements IGridMergeStrategy {
3550 field : string ,
3651 comparer : ( prevRecord : any , record : any , field : string ) => boolean = this . comparer ,
3752 result : any [ ] ,
38- activeRowIndexes : number [ ] ,
53+ activeRowIndexes : number [ ] ,
3954 grid ?: GridType
4055 ) {
4156 let prev = null ;
@@ -45,7 +60,7 @@ export class DefaultMergeStrategy implements IGridMergeStrategy {
4560 const recData = result [ index ] ;
4661 // if this is active row or some special record type - add and skip merging
4762 if ( activeRowIndexes . indexOf ( index ) != - 1 || ( grid && grid . isDetailRecord ( rec ) || grid . isGroupByRecord ( rec ) || grid . isChildGridRecord ( rec ) ) ) {
48- if ( ! recData ) {
63+ if ( ! recData ) {
4964 result . push ( rec ) ;
5065 }
5166 prev = null ;
0 commit comments