Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,17 @@ export class IgxGridUnmergeActivePipe implements PipeTransform {
}
let result = cloneArray(collection) as any;
uniqueRoots.forEach(x => {
const index = result.indexOf(x);
const index = collection.indexOf(x);
const colKeys = [...x.cellMergeMeta.keys()];
const cols = colsToMerge.filter(col => colKeys.indexOf(col.field) !== -1);
let res = [];
let data = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a set from the beginning, I think that you can ommit the concatenation in the for loop and instead of mapping the childRecs on line 141, you can just add them in a forEach loop.

for (const col of cols) {

let childData = x.cellMergeMeta.get(col.field).childRecords;
const childRecs = childData.map(rec => rec.recordRef);
const isDate = col?.dataType === 'date' || col?.dataType === 'dateTime';
const isTime = col?.dataType === 'time' || col?.dataType === 'dateTime';
res = this.grid.mergeStrategy.merge(
[x.recordRef, ...childRecs],
col.field,
col.mergingComparer,
res,
activeRowIndexes.map(ri => ri - index),
isDate,
isTime,
this.grid);

data = data.concat([x.recordRef, ...childRecs]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isnt it redundant to add the uniqueRoot recordRef each time? Can't you just add it once before looping through the columns?

}
const res = DataUtil.merge(Array.from(new Set(data)), cols, this.grid.mergeStrategy, activeRowIndexes.map(ri => ri - index), this.grid);
result = result.slice(0, index).concat(res, result.slice(index + res.length));
});

Expand Down
Loading