Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tg-group-pipe): add trigger and use data with transactions #13852

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
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,15 @@ export class IgxTreeGridGroupingPipe implements PipeTransform {
this.grid = grid;

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

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

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
Loading