Skip to content

Commit e89a0eb

Browse files
committed
chore(*): add summary sample that acces all grid data
1 parent b61f9cb commit e89a0eb

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

src/app/grid-groupby/grid-groupby.sample.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="density-chooser" style="margin-bottom: 16px">
55
<igx-buttongroup [values]="summaryModes" (onSelect)="selectSummaryMode($event)" style="display: block; width: 500px"></igx-buttongroup>
66
</div>
7-
<igx-grid #grid1 [data]="data" [allowFiltering]="true" [cellSelection]="'single'" [width]="'1200px'" (onGroupingDone)="onGroupingDoneHandler($event)" [hideGroupedColumns]="hideGroupedColumns" [(groupingExpressions)]='groupingExpressions'
7+
<igx-grid #grid1 [data]="data" [allowFiltering]="true" [cellSelection]="'single'" [width]="'1200px'" [hideGroupedColumns]="hideGroupedColumns"
88
[height]="'700px'" [(groupingExpansionState)]='expState' [rowSelectable]='true' [summaryCalculationMode]="summaryMode">
99
<igx-column *ngFor="let c of columns" [sortable]="true" [field]="c.field" [header]="c.field" [width]="c.width"
1010
[hidden]='c.hidden' [sortable]='true' [groupable]='c.groupable' [movable]='true' [pinned]='!!c.pinned' [editable]="true" [hasSummary]="true" [dataType]='c.dataType'>

src/app/grid-summaries/grid-summaries.sample.html

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<igx-grid #grid1 [data]="data" [autoGenerate]="false" [displayDensity]="'compact'" [width]="w" [height]="h"
2-
[paging]="false" [allowFiltering]='true' [filterMode]="'excelStyleFilter'">
2+
[paging]="false" [allowFiltering]='true' [filterMode]="'excelStyleFilter'" [summaryCalculationMode]="'rootAndChildLevels'">
33
<igx-column field="Index" header="Index" [width]="cw">
44
</igx-column>
55
<igx-column field="ProductID" header="Product ID" [width]="cw" [headerClasses]="'prodId'" [groupable]="groupable">
@@ -9,9 +9,6 @@
99
</igx-column>
1010
<igx-column field="ReorderLevel" [width]="cw" [sortable]="true" [groupable]="groupable" [filterable]="filterable"
1111
editable="true" [dataType]="'number'" [disableHiding]="disableHiding" [disablePinning]="disablePinning">
12-
<ng-template igxCell let-cell="cell" let-val let-row>
13-
{{val}} {{row.gridID}}
14-
</ng-template>
1512
</igx-column>
1613
<igx-column field="QuantityPerUnit" [width]="cw" header="QuantityPerUnit" [sortable]="true" [dataType]="'string'"
1714
[editable]="true">
@@ -23,16 +20,15 @@
2320
</ng-template>
2421
</igx-column>
2522
<igx-column field="OrderDate" [width]="cw" [dataType]="'date'" [hasSummary]="false" [sortable]="true">
26-
<ng-template igxCell let-cell="cell" let-val let-row>
27-
{{val}}
28-
</ng-template>
2923
</igx-column>
3024
<igx-column field="Discontinued" header="Discontinued" [dataType]="'boolean'" [width]="cw" [hasSummary]="false"
3125
editable="true">
3226
<ng-template igxCell let-cell="cell" let-val>
3327
{{val}}
3428
</ng-template>
3529
</igx-column>
30+
<igx-column field="Sum" [hasSummary]="true" [summaries]="mySummary">
31+
</igx-column>
3632
</igx-grid>
3733

3834
<div class="properties-input">

src/app/grid-summaries/grid-summaries.sample.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ class MySummary extends IgxNumberSummaryOperand {
1414
super();
1515
}
1616

17-
operate(data?: any[]): IgxSummaryResult[] {
18-
const result = super.operate(data);
19-
result.push({
20-
key: 'test',
21-
label: 'Test',
22-
summaryResult: data.filter((rec) => rec > 10 && rec < 30).length
23-
});
17+
operate(data?: any[], fieldName?): IgxSummaryResult[] {
18+
fieldName = fieldName === 'Sum' ? 'ReorderLevel' : fieldName;
19+
const result = super.operate(data, fieldName);
20+
if (!(fieldName === 'ReorderLevel')) {
21+
result.push({
22+
key: 'test',
23+
label: 'Total Discounted',
24+
summaryResult: data.filter((rec) => rec.Discontinued).length
25+
});
26+
}
2427

2528
return result;
2629
}

0 commit comments

Comments
 (0)