@@ -10,6 +10,8 @@ import { IPinningConfig } from '../common/grid.interface';
1010import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
1111import { IgxGridTransaction } from '../tree-grid' ;
1212import { IgxTransactionService } from '../../services' ;
13+ import { SortingDirection } from '../../data-operations/sorting-expression.interface' ;
14+ import { GridSummaryFunctions } from '../../test-utils/grid-functions.spec' ;
1315
1416describe ( 'Row Pinning #grid' , ( ) => {
1517 const FIXED_ROW_CONTAINER = '.igx-grid__tr--pinned ' ;
@@ -220,6 +222,63 @@ describe('Row Pinning #grid', () => {
220222 expect ( grid . getRowByIndex ( 0 ) . rowID ) . toBe ( fix . componentInstance . data [ 0 ] ) ;
221223 expect ( grid . getRowByIndex ( 1 ) . rowID ) . toBe ( fix . componentInstance . data [ 1 ] ) ;
222224 } ) ;
225+
226+ it ( 'should calculate global summaries with both pinned and unpinned collections' , ( ) => {
227+ // enable summaries for each column
228+ grid . columns . forEach ( c => {
229+ c . hasSummary = true ;
230+ } ) ;
231+ fix . detectChanges ( ) ;
232+
233+ grid . groupBy ( {
234+ fieldName : 'ContactTitle' , dir : SortingDirection . Asc , ignoreCase : false
235+ } ) ;
236+ fix . detectChanges ( ) ;
237+
238+ let row = grid . getRowByIndex ( 1 ) ;
239+ row . pinned = true ;
240+ fix . detectChanges ( ) ;
241+ let summaryRow = GridSummaryFunctions . getSummaryRowByDataRowIndex ( fix , 0 ) ;
242+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 0 , [ 'Count' ] , [ '27' ] ) ;
243+
244+ row = grid . pinnedRows [ 0 ] ;
245+ row . pinned = false ;
246+ fix . detectChanges ( ) ;
247+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
248+ summaryRow = GridSummaryFunctions . getSummaryRowByDataRowIndex ( fix , 0 ) ;
249+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 0 , [ 'Count' ] , [ '27' ] ) ;
250+ } ) ;
251+
252+ it ( 'should calculate groupby row summaries only within unpinned collection' , ( ) => {
253+ // enable summaries for each column
254+ grid . columns . forEach ( c => {
255+ c . hasSummary = true ;
256+ } ) ;
257+ fix . detectChanges ( ) ;
258+
259+ grid . groupBy ( {
260+ fieldName : 'ContactTitle' , dir : SortingDirection . Asc , ignoreCase : false
261+ } ) ;
262+ fix . detectChanges ( ) ;
263+
264+ let row = grid . getRowByIndex ( 1 ) ;
265+ row . pinned = true ;
266+ fix . detectChanges ( ) ;
267+
268+ expect ( grid . pinnedRows . length ) . toBe ( 1 ) ;
269+
270+ // get first summary row and make sure that the pinned record is not contained within the calculations
271+ let summaryRow = GridSummaryFunctions . getSummaryRowByDataRowIndex ( fix , 3 ) ;
272+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 0 , [ 'Count' ] , [ '1' ] ) ;
273+
274+ // unpin the row and check if the summary is recalculated
275+ row = grid . pinnedRows [ 0 ] ;
276+ row . pinned = false ;
277+ fix . detectChanges ( ) ;
278+ expect ( grid . pinnedRows . length ) . toBe ( 0 ) ;
279+ summaryRow = GridSummaryFunctions . getSummaryRowByDataRowIndex ( fix , 3 ) ;
280+ GridSummaryFunctions . verifyColumnSummaries ( summaryRow , 0 , [ 'Count' ] , [ '2' ] ) ;
281+ } ) ;
223282 } ) ;
224283
225284 describe ( ' Editing ' , ( ) => {
0 commit comments