Skip to content

Commit

Permalink
fix(tg-group-pipe): add trigger and use data with transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
igdmdimitrov committed Jan 31, 2024
1 parent e3c852a commit 4710834
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Pipe, PipeTransform } from '@angular/core';
import { formatDate } from '../../core/utils';
import { GridColumnDataType } from '../../data-operations/data-util';
import { cloneArray, formatDate } from '../../core/utils';
import { DataUtil, GridColumnDataType } from '../../data-operations/data-util';
import { IGroupingExpression } from '../../data-operations/grouping-expression.interface';
import { GridType } from '../common/grid.interface';
import { IgxSorting } from '../common/strategy';
Expand Down Expand Up @@ -54,7 +54,8 @@ export class IgxTreeGridGroupingPipe implements PipeTransform {
groupKey: string,
childDataKey: string,
grid: GridType,
aggregations?: ITreeGridAggregation[]
aggregations?: ITreeGridAggregation[],
_pipeTrigger?: number
): any[] {
if (groupingExpressions.length === 0) {
return collection;
Expand All @@ -67,7 +68,13 @@ export class IgxTreeGridGroupingPipe implements PipeTransform {
this.grid = grid;

const result = [];
const groupedRecords = this.groupByMultiple(collection, groupingExpressions);

const updatedCollection = DataUtil.mergeTransactions(
cloneArray(collection, true),
grid.transactions.getAggregatedChanges(true),
grid.primaryKey);

const groupedRecords = this.groupByMultiple(updatedCollection, groupingExpressions);
this.flattenGrouping(groupedRecords, groupKey,
childDataKey, result, aggregations);

Expand Down
2 changes: 1 addition & 1 deletion src/app/tree-grid-groupby/tree-grid-groupby.sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<igx-tree-grid #grid1
[moving]="true"
[data]="data | treeGridGrouping:groupingExpressions:groupKey:childDataKey:grid1:employeeAggregations"
[data]="data | treeGridGrouping:groupingExpressions:groupKey:childDataKey:grid1:employeeAggregations:pipeTrigger"
selectionType="multi"
[childDataKey]="childDataKey"
[rowSelection]="selectionMode"
Expand Down
1 change: 1 addition & 0 deletions src/app/tree-grid-groupby/tree-grid-groupby.sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class TreeGridGroupBySampleComponent implements OnInit {
public childDataKey = 'ChildCompanies';
public sorting = IgxGroupedTreeGridSorting.instance();
public filteringStrategy = new TreeGridFilteringStrategy([this.groupKey]);
public pipeTrigger = 0;

public employeeAggregations: ITreeGridAggregation[] = [{
field: 'Employees',
Expand Down

0 comments on commit 4710834

Please sign in to comment.