@@ -18,14 +18,16 @@ import {
18
18
MultiColumnHeadersExportComponent ,
19
19
GridWithEmptyColumnsComponent ,
20
20
ColumnsAddedOnInitComponent ,
21
- GridWithThreeLevelsOfMultiColumnHeadersAndTwoRowsExportComponent
21
+ GridWithThreeLevelsOfMultiColumnHeadersAndTwoRowsExportComponent ,
22
+ GroupedGridWithSummariesComponent ,
23
+ GridCurrencySummariesComponent
22
24
} from '../../test-utils/grid-samples.spec' ;
23
25
import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
24
26
import { first } from 'rxjs/operators' ;
25
27
import { DefaultSortingStrategy , SortingDirection } from '../../data-operations/sorting-strategy' ;
26
28
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition' ;
27
29
import { configureTestSuite } from '../../test-utils/configure-suite' ;
28
- import { IgxTreeGridPrimaryForeignKeyComponent } from '../../test-utils/tree-grid-components.spec' ;
30
+ import { IgxTreeGridPrimaryForeignKeyComponent , IgxTreeGridSummariesKeyComponent } from '../../test-utils/tree-grid-components.spec' ;
29
31
import { IgxTreeGridModule , IgxTreeGridComponent } from '../../grids/tree-grid/public_api' ;
30
32
import { IgxNumberFilteringOperand } from '../../data-operations/filtering-condition' ;
31
33
import { UIInteractions , wait } from '../../test-utils/ui-interactions.spec' ;
@@ -34,7 +36,8 @@ import { FilteringExpressionsTree } from '../../data-operations/filtering-expres
34
36
import { FilteringLogic } from '../../data-operations/filtering-expression.interface' ;
35
37
import { IgxHierarchicalGridExportComponent ,
36
38
IgxHierarchicalGridMultiColumnHeaderIslandsExportComponent ,
37
- IgxHierarchicalGridMultiColumnHeadersExportComponent
39
+ IgxHierarchicalGridMultiColumnHeadersExportComponent ,
40
+ IgxHierarchicalGridSummariesExportComponent
38
41
} from '../../test-utils/hierarchical-grid-components.spec' ;
39
42
import { IgxHierarchicalGridModule ,
40
43
IgxHierarchicalGridComponent ,
@@ -68,7 +71,11 @@ describe('Excel Exporter', () => {
68
71
IgxHierarchicalGridMultiColumnHeaderIslandsExportComponent ,
69
72
GridWithThreeLevelsOfMultiColumnHeadersAndTwoRowsExportComponent ,
70
73
IgxPivotGridMultipleRowComponent ,
71
- IgxPivotGridTestComplexHierarchyComponent
74
+ IgxPivotGridTestComplexHierarchyComponent ,
75
+ IgxTreeGridSummariesKeyComponent ,
76
+ IgxHierarchicalGridSummariesExportComponent ,
77
+ GroupedGridWithSummariesComponent ,
78
+ GridCurrencySummariesComponent
72
79
] ,
73
80
imports : [ IgxGridModule , IgxTreeGridModule , IgxHierarchicalGridModule , IgxPivotGridModule , NoopAnimationsModule ]
74
81
} ) . compileComponents ( ) ;
@@ -1211,6 +1218,97 @@ describe('Excel Exporter', () => {
1211
1218
} ) ;
1212
1219
} ) ;
1213
1220
1221
+
1222
+ describe ( '' , ( ) => {
1223
+ let fix ;
1224
+ let grid : any ;
1225
+
1226
+ beforeEach ( waitForAsync ( ( ) => {
1227
+ options = createExportOptions ( 'GirdSummariesExcelExport' , 50 ) ;
1228
+ } ) ) ;
1229
+
1230
+ it ( 'should export grid with summaries based on summaryCalculationMode' , async ( ) => {
1231
+ fix = TestBed . createComponent ( GroupedGridWithSummariesComponent ) ;
1232
+ fix . detectChanges ( ) ;
1233
+ await wait ( 300 ) ;
1234
+
1235
+ grid = fix . componentInstance . grid ;
1236
+ grid . summaryCalculationMode = 'rootLevelOnly' ;
1237
+
1238
+ await exportAndVerify ( grid , options , actualData . exportGridWithSummaries ) ;
1239
+
1240
+ ( grid as IgxGridComponent ) . groupBy ( { fieldName : 'Shipped' , dir : SortingDirection . Asc , ignoreCase : false } ) ;
1241
+ ( grid as IgxGridComponent ) . groupBy ( { fieldName : 'City' , dir : SortingDirection . Asc , ignoreCase : false } ) ;
1242
+ ( grid as IgxGridComponent ) . groupBy ( { fieldName : 'ContactTitle' , dir : SortingDirection . Asc , ignoreCase : false } ) ;
1243
+
1244
+ fix . detectChanges ( ) ;
1245
+
1246
+ await exportAndVerify ( grid , options , actualData . exportGroupedGridWithSummariesRootLevelOnly ) ;
1247
+
1248
+ grid . summaryCalculationMode = 'childLevelsOnly' ;
1249
+ fix . detectChanges ( ) ;
1250
+
1251
+ await exportAndVerify ( grid , options , actualData . exportGroupedGridWithSummariesChildLevelsOnly ) ;
1252
+
1253
+ grid . summaryCalculationMode = 'rootAndChildLevels' ;
1254
+ fix . detectChanges ( ) ;
1255
+
1256
+ await exportAndVerify ( grid , options , actualData . exportGroupedGridWithSummariesRootAndChildLevels ) ;
1257
+ } ) ;
1258
+
1259
+ it ( 'should export tree grid with summaries' , async ( ) => {
1260
+ fix = TestBed . createComponent ( IgxTreeGridSummariesKeyComponent ) ;
1261
+ fix . detectChanges ( ) ;
1262
+ await wait ( 300 ) ;
1263
+ grid = fix . componentInstance . treeGrid ;
1264
+
1265
+ grid . toggleRow ( grid . getRowByIndex ( 2 ) . key ) ;
1266
+ grid . toggleRow ( grid . getRowByIndex ( 0 ) . key ) ;
1267
+ grid . toggleRow ( grid . getRowByIndex ( 3 ) . key ) ;
1268
+ fix . detectChanges ( ) ;
1269
+
1270
+ await exportAndVerify ( grid , options , actualData . exportTreeGridWithSummaries ) ;
1271
+ } ) ;
1272
+
1273
+ it ( 'should export hierarchical grid with summaries' , async ( ) => {
1274
+ fix = TestBed . createComponent ( IgxHierarchicalGridSummariesExportComponent ) ;
1275
+ fix . detectChanges ( ) ;
1276
+ await wait ( 300 ) ;
1277
+ grid = fix . componentInstance . hGrid ;
1278
+
1279
+ const firstRow = grid . gridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
1280
+ const secondRow = grid . gridAPI . get_row_by_index ( 1 ) as IgxHierarchicalRowComponent ;
1281
+
1282
+ UIInteractions . simulateClickAndSelectEvent ( firstRow . expander ) ;
1283
+ fix . detectChanges ( ) ;
1284
+ expect ( firstRow . expanded ) . toBe ( true ) ;
1285
+
1286
+ let childGrids = grid . gridAPI . getChildGrids ( false ) ;
1287
+
1288
+ const firstChildGrid = childGrids [ 0 ] ;
1289
+ const firstChildRow = firstChildGrid . gridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
1290
+
1291
+ UIInteractions . simulateClickAndSelectEvent ( firstChildRow . expander ) ;
1292
+ fix . detectChanges ( ) ;
1293
+ expect ( firstChildRow . expanded ) . toBe ( true ) ;
1294
+
1295
+ UIInteractions . simulateClickAndSelectEvent ( secondRow . expander ) ;
1296
+ fix . detectChanges ( ) ;
1297
+ expect ( secondRow . expanded ) . toBe ( true ) ;
1298
+
1299
+ childGrids = grid . gridAPI . getChildGrids ( false ) ;
1300
+
1301
+ const thirdChildGrid = childGrids [ 1 ] ;
1302
+ const thirdChildRow = thirdChildGrid . gridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
1303
+
1304
+ UIInteractions . simulateClickAndSelectEvent ( thirdChildRow . expander ) ;
1305
+ fix . detectChanges ( ) ;
1306
+ expect ( thirdChildRow . expanded ) . toBe ( true ) ;
1307
+
1308
+ await exportAndVerify ( grid , options , actualData . exportHierarchicalGridWithSummaries ) ;
1309
+ } ) ;
1310
+ } ) ;
1311
+
1214
1312
describe ( '' , ( ) => {
1215
1313
let fix ;
1216
1314
let grid : IgxPivotGridComponent ;
0 commit comments