-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathhierarchical-grid-allData-summary.component.ts
73 lines (62 loc) · 2.08 KB
/
hierarchical-grid-allData-summary.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { Component, OnInit, ViewChild } from "@angular/core";
import { IgxHierarchicalGridComponent,
IgxNumberSummaryOperand,
IgxSummaryOperand,
IgxSummaryResult } from "igniteui-angular";
import { SINGERS } from "../data";
class CustomNumberSummary extends IgxNumberSummaryOperand {
constructor() {
super();
}
public operate(data?: any[]): IgxSummaryResult[] {
const result = super.operate(data);
result.pop();
result.pop();
return result;
}
}
class GrammySummary extends IgxSummaryOperand {
constructor() {
super();
}
public operate(data?: any[], allData = [], fieldName = ""): IgxSummaryResult[] {
const result = [];
result.push({
key: "nominatedSingers",
label: "Nominated Singers",
summaryResult: allData.filter((rec) => rec["GrammyNominations"] > 0).length
});
result.push({
key: "singersWithAwards",
label: "Singers with Awards",
summaryResult: allData.filter((rec) => rec["GrammyAwards"] > 0).length
});
result.push({
key: "nominations",
label: "Total Nominations",
summaryResult: IgxNumberSummaryOperand.sum(allData.map(r => r["GrammyNominations"]))
});
result.push({
key: "awards",
label: "Total Awards",
summaryResult: IgxNumberSummaryOperand.sum(allData.map(r => r["GrammyAwards"]))
});
return result;
}
}
@Component({
selector: "hierarchical-grid-allData-summary",
styleUrls: ["./hierarchical-grid-allData-summary.component.scss"],
templateUrl: "hierarchical-grid-allData-summary.component.html"
})
export class HGridAllDataSummaryComponent implements OnInit {
public localdata;
public grammySummary = GrammySummary;
public numberSummary = CustomNumberSummary;
@ViewChild("hierarchicalGrid", { static: true })
private hierarchicalGrid: IgxHierarchicalGridComponent;
constructor() {}
public ngOnInit(): void {
this.localdata = SINGERS;
}
}