From 672db5f903d2a696e74cc04bf76d74ae7a6214de Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Thu, 7 Jan 2021 10:23:25 -0500 Subject: [PATCH] fix(plugins): throw when Tree Data used with Pagination, closes #658 --- .../__tests__/angular-slickgrid-constructor.spec.ts | 11 +++++++++++ .../components/angular-slickgrid.component.ts | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts b/src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts index 7d7547cf9..f857ca3cf 100644 --- a/src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts +++ b/src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts @@ -1533,6 +1533,17 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () = }); describe('Tree Data View', () => { + it('should throw an error when enableTreeData is enabled with Pagination since that is not supported', (done) => { + try { + component.gridOptions = { enableTreeData: true, enablePagination: true } as GridOption; + component.ngAfterViewInit(); + } catch (e) { + expect(e.toString()).toContain('[Angular-Slickgrid] It looks like you are trying to use Tree Data with Pagination but unfortunately that is simply not supported because of its complexity.'); + component.destroy(); + done(); + } + }); + it('should throw an error when enableTreeData is enabled without passing a "columnId"', (done) => { try { component.gridOptions = { enableTreeData: true, treeDataOptions: {} } as GridOption; diff --git a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts index 4bf967b99..d0c7cd8bb 100644 --- a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts +++ b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts @@ -634,6 +634,11 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn } }); + // Tree Data with Pagiantion is not supported, throw an error when user tries to do that + if (this.gridOptions && this.gridOptions.enableTreeData && this.gridOptions.enablePagination) { + throw new Error('[Angular-Slickgrid] It looks like you are trying to use Tree Data with Pagination but unfortunately that is simply not supported because of its complexity.'); + } + // when dealing with Tree Data View, make sure we have necessary tree data options if (this.gridOptions && this.gridOptions.enableTreeData && (!this.gridOptions.treeDataOptions || !this.gridOptions.treeDataOptions.columnId)) { throw new Error('[Angular-Slickgrid] When enabling tree data, you must also provide the "treeDataOption" property in your Grid Options with "childrenPropName" or "parentPropName" (depending if your array is hierarchical or flat) for the Tree Data to work properly');