From f4f11f60b58dcb0bb7341da339243aa9a7fc8037 Mon Sep 17 00:00:00 2001 From: astaev Date: Thu, 3 Jan 2019 14:28:13 +0200 Subject: [PATCH] fix(Exporter): #3332 Improve the fix and test --- .../excel/excel-exporter-grid.spec.ts | 26 +++++++++++++++++++ .../exporter-common/base-export-service.ts | 3 +-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts b/projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts index ff6e7a45a74..f645446d478 100644 --- a/projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts +++ b/projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts @@ -470,6 +470,32 @@ describe('Excel Exporter', () => { error = ex.message; } expect(error).toMatch('Can create an outline of up to eight levels!'); + + treeGrid.deleteRowById(9); + fix.detectChanges(); + await wait(16); + + error = ''; + try { + exporter.export(treeGrid, options); + await wait(); + } catch (ex) { + error = ex.message; + } + expect(error).toEqual(''); + + treeGrid.addRow({ ID: 9, ParentID: 8, Name: 'Test', JobTitle: '', Age: 49 }); + fix.detectChanges(); + await wait(16); + + error = ''; + try { + exporter.export(treeGrid, options); + await wait(); + } catch (ex) { + error = ex.message; + } + expect(error).toMatch('Can create an outline of up to eight levels!'); }); }); diff --git a/projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts b/projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts index 42b22eb17f9..07b18db4f34 100644 --- a/projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts +++ b/projects/igniteui-angular/src/lib/services/exporter-common/base-export-service.ts @@ -192,6 +192,7 @@ export abstract class IgxBaseExporter { } private prepareData(grid: any, options: IgxExporterOptionsBase): any[] { + this.flatRecords = []; let rootRecords = grid.rootRecords; this._isTreeGrid = rootRecords !== undefined; @@ -210,7 +211,6 @@ export abstract class IgxBaseExporter { }; if (this._isTreeGrid) { - this.flatRecords = []; rootRecords = DataUtil.treeGridFilter(rootRecords, filteringState); this.prepareHierarchicalData(rootRecords); data = this.flatRecords; @@ -225,7 +225,6 @@ export abstract class IgxBaseExporter { this._sort = cloneValue(grid.sortingExpressions[0]); if (this._isTreeGrid) { - this.flatRecords = []; rootRecords = DataUtil.treeGridSort(rootRecords, grid.sortingExpressions); this.prepareHierarchicalData(rootRecords); data = this.flatRecords;