66 IgxDateSummaryOperand ,
77 IgxGridModule ,
88 IgxNumberSummaryOperand ,
9+ IgxSummaryOperand ,
910 IgxSummaryResult ,
1011 IgxGridGroupByRowComponent
1112} from './index' ;
@@ -149,6 +150,23 @@ describe('IgxGrid - Summaries #grid', () => {
149150 GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 3 , [ 'Count' , 'Sum' , 'Avg' ] , [ '0' , '0' , '0' ] ) ;
150151 } ) ) ;
151152
153+ it ( 'should properly calculate all data custom summaries height' , fakeAsync ( ( ) => {
154+ const fixture = TestBed . createComponent ( CustomSummariesComponent ) ;
155+ const gridComp = fixture . componentInstance . grid1 ;
156+ fixture . detectChanges ( ) ;
157+
158+ gridComp . getColumnByName ( 'UnitsInStock' ) . summaries = fixture . componentInstance . allDataAvgSummary ;
159+ gridComp . getColumnByName ( 'OrderDate' ) . summaries = fixture . componentInstance . allDataAvgSummary ;
160+ fixture . detectChanges ( ) ;
161+
162+ const summaryRow = fixture . debugElement . query ( By . css ( SUMMARY_ROW ) ) ;
163+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 3 , [ 'Count' , 'Test 1' , 'Test 2' ] , [ '10' , '50' , '150' ] ) ;
164+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 4 , [ 'Count' , 'Test 3' ] , [ '10' , '850' ] ) ;
165+
166+ const tFootHeight = fixture . debugElement . query ( By . css ( '.igx-grid__tfoot' ) ) . nativeElement . getBoundingClientRect ( ) . height ;
167+ expect ( tFootHeight ) . toBeGreaterThanOrEqual ( 3 * gridComp . defaultSummaryHeight ) ;
168+ } ) ) ;
169+
152170 it ( `Should update summary section when the column is outside of the
153171 viewport and have identical width with others` , ( async ( ) => {
154172 const fixture = TestBed . createComponent ( ProductsComponent ) ;
@@ -2490,6 +2508,36 @@ class InStockSummary extends IgxNumberSummaryOperand {
24902508 }
24912509}
24922510
2511+ class AllDataAvgSummary extends IgxSummaryOperand {
2512+ constructor ( ) {
2513+ super ( ) ;
2514+ }
2515+
2516+ public operate ( data ?: any [ ] , allData = [ ] , fieldName = '' ) : IgxSummaryResult [ ] {
2517+ const result = super . operate ( data ) ;
2518+ if ( fieldName === 'UnitsInStock' ) {
2519+ result . push ( {
2520+ key : 'long' ,
2521+ label : 'Test 1' ,
2522+ summaryResult : 50
2523+ } ) ;
2524+ result . push ( {
2525+ key : 'long' ,
2526+ label : 'Test 2' ,
2527+ summaryResult : 150
2528+ } ) ;
2529+ }
2530+ if ( fieldName === 'OrderDate' ) {
2531+ result . push ( {
2532+ key : 'long' ,
2533+ label : 'Test 3' ,
2534+ summaryResult : 850
2535+ } ) ;
2536+ }
2537+ return result ;
2538+ }
2539+ }
2540+
24932541@Component ( {
24942542 template : `
24952543 <igx-grid #grid1 [data]="data" [primaryKey]="'ProductID'" [allowFiltering]="true">
@@ -2516,6 +2564,7 @@ export class CustomSummariesComponent {
25162564 public dealsSummaryMinMax = DealsSummaryMinMax ;
25172565 public earliest = EarliestSummary ;
25182566 public inStockSummary = InStockSummary ;
2567+ public allDataAvgSummary = AllDataAvgSummary ;
25192568}
25202569
25212570@Component ( {
0 commit comments