@@ -13,6 +13,7 @@ import { GridFunctions } from '../../test-utils/grid-functions.spec';
13
13
import { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
14
14
import { IgxGridTransaction } from '../tree-grid' ;
15
15
import { IgxTransactionService } from '../../services' ;
16
+ import { GridSummaryFunctions } from '../../test-utils/grid-functions.spec' ;
16
17
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition' ;
17
18
18
19
describe ( 'Row Pinning #grid' , ( ) => {
@@ -387,6 +388,63 @@ describe('Row Pinning #grid', () => {
387
388
// check last pinned and expanded is fully in view
388
389
expect ( firstRowDetail . getBoundingClientRect ( ) . bottom - grid . tbody . nativeElement . getBoundingClientRect ( ) . bottom ) . toBe ( 0 ) ;
389
390
} ) ;
391
+
392
+ it ( 'should calculate global summaries with both pinned and unpinned collections' , ( ) => {
393
+ // enable summaries for each column
394
+ grid . columns . forEach ( c => {
395
+ c . hasSummary = true ;
396
+ } ) ;
397
+ fix . detectChanges ( ) ;
398
+
399
+ grid . groupBy ( {
400
+ fieldName : 'ContactTitle' , dir : SortingDirection . Asc , ignoreCase : false
401
+ } ) ;
402
+ fix . detectChanges ( ) ;
403
+
404
+ let row = grid . getRowByIndex ( 1 ) ;
405
+ row . pinned = true ;
406
+ fix . detectChanges ( ) ;
407
+ let summaryRow = GridSummaryFunctions . getSummaryRowByDataRowIndex ( fix , 0 ) ;
408
+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 0 , [ 'Count' ] , [ '27' ] ) ;
409
+
410
+ row = grid . pinnedRows [ 0 ] ;
411
+ row . pinned = false ;
412
+ fix . detectChanges ( ) ;
413
+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
414
+ summaryRow = GridSummaryFunctions . getSummaryRowByDataRowIndex ( fix , 0 ) ;
415
+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 0 , [ 'Count' ] , [ '27' ] ) ;
416
+ } ) ;
417
+
418
+ it ( 'should calculate groupby row summaries only within unpinned collection' , ( ) => {
419
+ // enable summaries for each column
420
+ grid . columns . forEach ( c => {
421
+ c . hasSummary = true ;
422
+ } ) ;
423
+ fix . detectChanges ( ) ;
424
+
425
+ grid . groupBy ( {
426
+ fieldName : 'ContactTitle' , dir : SortingDirection . Asc , ignoreCase : false
427
+ } ) ;
428
+ fix . detectChanges ( ) ;
429
+
430
+ let row = grid . getRowByIndex ( 1 ) ;
431
+ row . pinned = true ;
432
+ fix . detectChanges ( ) ;
433
+
434
+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
435
+
436
+ // get first summary row and make sure that the pinned record is not contained within the calculations
437
+ let summaryRow = GridSummaryFunctions . getSummaryRowByDataRowIndex ( fix , 3 ) ;
438
+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 0 , [ 'Count' ] , [ '1' ] ) ;
439
+
440
+ // unpin the row and check if the summary is recalculated
441
+ row = grid . pinnedRows [ 0 ] ;
442
+ row . pinned = false ;
443
+ fix . detectChanges ( ) ;
444
+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
445
+ summaryRow = GridSummaryFunctions . getSummaryRowByDataRowIndex ( fix , 3 ) ;
446
+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 0 , [ 'Count' ] , [ '2' ] ) ;
447
+ } ) ;
390
448
} ) ;
391
449
392
450
describe ( ' Editing ' , ( ) => {
0 commit comments