Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit e3e623d

Browse files
authored
Merge pull request #669 from ghiscoding/bugfix/error-out-tree-data-with-pagination
fix(plugins): throw when Tree Data used with Pagination, closes #658
2 parents 6e55fd6 + 672db5f commit e3e623d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/app/modules/angular-slickgrid/components/__tests__/angular-slickgrid-constructor.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,17 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
15331533
});
15341534

15351535
describe('Tree Data View', () => {
1536+
it('should throw an error when enableTreeData is enabled with Pagination since that is not supported', (done) => {
1537+
try {
1538+
component.gridOptions = { enableTreeData: true, enablePagination: true } as GridOption;
1539+
component.ngAfterViewInit();
1540+
} catch (e) {
1541+
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.');
1542+
component.destroy();
1543+
done();
1544+
}
1545+
});
1546+
15361547
it('should throw an error when enableTreeData is enabled without passing a "columnId"', (done) => {
15371548
try {
15381549
component.gridOptions = { enableTreeData: true, treeDataOptions: {} } as GridOption;

src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,11 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
634634
}
635635
});
636636

637+
// Tree Data with Pagiantion is not supported, throw an error when user tries to do that
638+
if (this.gridOptions && this.gridOptions.enableTreeData && this.gridOptions.enablePagination) {
639+
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.');
640+
}
641+
637642
// when dealing with Tree Data View, make sure we have necessary tree data options
638643
if (this.gridOptions && this.gridOptions.enableTreeData && (!this.gridOptions.treeDataOptions || !this.gridOptions.treeDataOptions.columnId)) {
639644
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');

0 commit comments

Comments
 (0)