Skip to content

Commit

Permalink
fix(plugins): throw error when Tree Data used with Pagination (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Jan 7, 2021
1 parent a76b3a3 commit 85718e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Expand Up @@ -1783,6 +1783,17 @@ describe('Slick-Vanilla-Grid-Bundle 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.initialization(divContainer, slickEventHandler);
} catch (e) {
expect(e.toString()).toContain('[Slickgrid-Universal] It looks like you are trying to use Tree Data with Pagination but unfortunately that is simply not supported because of its complexity.');
component.dispose();
done();
}
});

it('should throw an error when enableTreeData is enabled without passing a "columnId"', (done) => {
try {
component.gridOptions = { enableTreeData: true, treeDataOptions: {} } as unknown as GridOption;
Expand Down
Expand Up @@ -523,6 +523,11 @@ export class SlickVanillaGridBundle {
}

if (this._gridOptions?.enableTreeData) {
// Tree Data with Pagiantion is not supported, throw an error when user tries to do that
if (this.gridOptions.enablePagination) {
throw new Error('[Slickgrid-Universal] It looks like you are trying to use Tree Data with Pagination but unfortunately that is simply not supported because of its complexity.');
}

if (!this._gridOptions.treeDataOptions || !this._gridOptions.treeDataOptions.columnId) {
throw new Error('[Slickgrid-Universal] 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');
}
Expand Down

0 comments on commit 85718e1

Please sign in to comment.