1
+ < div class ="control-section ">
2
+ < ej-grid [dataSource] ="data " [allowPaging] ="true " [allowGrouping] ="true " [groupSettings] ="groupSettings ">
3
+ < e-columns >
4
+ < e-column field ='CategoryName ' headerText ='Category Name ' width ='170 '> </ e-column >
5
+ < e-column field ='ProductName ' headerText ='Product Name ' width ='150 '> </ e-column >
6
+ < e-column field ='QuantityPerUnit ' headerText ='Quantity per unit ' width ='180 ' textAlign ="right "> </ e-column >
7
+ < e-column field ='UnitsInStock ' headerText ='Units In Stock ' width ='150 ' textAlign ="right "> </ e-column >
8
+ < e-column field ='Discontinued ' width ='170 ' textAlign ="center " [displayAsCheckBox] ="true " type ="boolean "> </ e-column >
9
+ </ e-columns >
10
+ < e-aggregates >
11
+ < e-aggregate >
12
+ < e-columns >
13
+ < e-column type ="sum " field ="UnitsInStock ">
14
+ < template #groupFooterTemplate let-data > Total units: {{data.sum}}</ template >
15
+ </ e-column >
16
+ </ e-columns >
17
+ </ e-aggregate >
18
+ < e-aggregate >
19
+ < e-columns >
20
+ < e-column type ="truecount " field ="Discontinued ">
21
+ < template #groupFooterTemplate let-data > Discontinued: {{data.truecount}}</ template >
22
+ </ e-column >
23
+ </ e-columns >
24
+ </ e-aggregate >
25
+ < e-aggregate >
26
+ < e-columns >
27
+ < e-column type ="max " field ="UnitsInStock ">
28
+ < template #groupCaptionTemplate let-data > Maximum: {{data.max}}</ template >
29
+ </ e-column >
30
+ </ e-columns >
31
+ </ e-aggregate >
32
+ </ e-aggregates >
33
+ </ ej-grid >
34
+
35
+ < div id ="description ">
36
+ < p > The Grid supports aggregates which will be displayed at the footer, group footer and group caption of the Grid.
37
+ The aggregate configurations can be provided by the < code > < a target ="_blank " class ="code "
38
+ href ="http://ej2.syncfusion.com/documentation/grid/api-grid.html ">
39
+ aggregates
40
+ </ a > </ code > property.</ p >
41
+ < p > The built-in aggregates are,</ p >
42
+ < ul >
43
+ < li > < code > sum</ code > </ li >
44
+ < li > < code > average</ code > </ li >
45
+ < li > < code > min</ code > </ li >
46
+ < li > < code > max</ code > </ li >
47
+ < li > < code > count</ code > </ li >
48
+ < li > < code > truecount</ code > </ li >
49
+ < li > < code > falsecount</ code > </ li >
50
+ < li > < code > custom</ code > - Requires the < code > < a target ="_blank " class ="code "
51
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#customaggregate-string ">
52
+ customAggregate
53
+ </ a > </ code > property to perform aggregation.
54
+ The custom aggregate value can be accessed inside template using the key < code > custom</ code > </ li >
55
+ </ ul >
56
+ < p >
57
+ In this demo, the < code > < a target ="_blank " class ="code "
58
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#groupfootertemplate-string ">
59
+ groupFooterTemplate</ a > </ code > property is used to display group footer aggregation for the < strong > < i > Unit In Stocks</ i > </ strong > and < strong > < i > Discontinued</ i > </ strong > columns and < code > < a target ="_blank " class ="code "
60
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#groupcaptiontemplate-string ">
61
+ groupCaptionTemplate</ a > </ code > property is used to display group caption aggregation for the < strong > < i > Unit In Stocks</ i > </ strong > column.
62
+ </ p >
63
+ < p > To enable group footer aggregation for < strong > < i > Unit In Stocks</ i > </ strong > column, the < code > sum</ code > aggregate type is used by setting the < code > < a target ="_blank " class ="code "
64
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#type-string---string ">
65
+ type</ a > </ code > and the < code > < a target ="_blank " class ="code "
66
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#field-string ">
67
+ field</ a > </ code > property is set as < strong > < i > UnitsInStock</ i > </ strong > which will be used to perform aggregation.
68
+ The aggregate value is accessed inside the < code > < a target ="_blank " class ="code "
69
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#groupfootertemplate-string ">
70
+ groupFooterTemplate</ a > </ code > using its < code > < a target ="_blank " class ="code "
71
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#type-string---string ">
72
+ type</ a > </ code > name (< code > sum</ code > ).
73
+ </ p >
74
+ < p > To enable group caption aggregation for < strong > < i > Unit In Stocks</ i > </ strong > column, the < code > max</ code > aggregate type is used by setting the < code > < a target ="_blank " class ="code "
75
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#type-string---string ">
76
+ type</ a > </ code > and the < code > < a target ="_blank " class ="code "
77
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#field-string ">
78
+ field</ a > </ code > property is set as < strong > < i > UnitsInStock</ i > </ strong > which will be used to perform aggregation.
79
+ The aggregate value is accessed inside the< code > < a target ="_blank " class ="code "
80
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#groupcaptiontemplate-string ">
81
+ groupCaptionTemplate</ a > </ code > using its < code > < a target ="_blank " class ="code "
82
+ href ="http://ej2.syncfusion.com/documentation/grid/api-aggregateColumn.html#type-string---string ">
83
+ type</ a > </ code > name (< code > max</ code > ).
84
+ </ p >
85
+
86
+ < p style ="font-weight: 500 "> Injecting Module</ p >
87
+ < p >
88
+ Grid component features are segregated into individual feature-wise modules. To use aggregate feature, we need to inject
89
+ < code > AggregateService</ code > into the < code > @NgModule.providers</ code > section. Since grouping feature is required
90
+ to show group aggreations, we also need to inject < code > GroupService</ code > .
91
+ </ p >
92
+ </ div >
93
+ </ div >
0 commit comments