Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,14 @@ describe('Angular-Slickgrid Custom Component instantiated via Constructor', () =
expect(component.gridOptions.enableMouseWheelScrollHandler).toBeTrue();
});

it('should throw an error when [gridOptions] and/or [columnDefinitions] is undefined', (done) => {
it('should throw an error when [columnDefinitions] is undefined', (done) => {
try {
component.gridOptions = undefined as any;
component.columnDefinitions = '' as any;
component.gridOptions = gridOptions;
component.ngAfterViewInit();
component.dataset = [];
} catch (e: any) {
expect(e.toString()).toContain('Using `<angular-slickgrid>` requires [gridOptions] and [columnDefinitions]');
expect(e.toString()).toContain('Using `<angular-slickgrid>` requires [columnDefinitions]');
component.destroy();
done();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class AngularSlickgridComponent<TData = any> implements AfterViewInit, On

@Input() customDataView: any;
@Input() gridId = '';
@Input() gridOptions!: GridOption;
@Input() gridOptions: GridOption = {};

@Input()
get paginationOptions(): Pagination | undefined {
Expand Down Expand Up @@ -359,8 +359,8 @@ export class AngularSlickgridComponent<TData = any> implements AfterViewInit, On
}

ngAfterViewInit() {
if (!this.gridOptions || !this.columnDefinitions) {
throw new Error('Using `<angular-slickgrid>` requires [gridOptions] and [columnDefinitions], it seems that you might have forgot to provide them since at least of them is undefined.');
if (!this.columnDefinitions) {
throw new Error('Using `<angular-slickgrid>` requires [columnDefinitions], it seems that you might have forgot to provide the missing bindable input.');
}

this.initialization(this._eventHandler);
Expand Down Expand Up @@ -424,8 +424,10 @@ export class AngularSlickgridComponent<TData = any> implements AfterViewInit, On
}
this.backendServiceApi = undefined;
}
for (const prop of Object.keys(this.columnDefinitions)) {
(this.columnDefinitions as any)[prop] = null;
if (this.columnDefinitions) {
for (const prop of Object.keys(this.columnDefinitions)) {
(this.columnDefinitions as any)[prop] = null;
}
}
for (const prop of Object.keys(this.sharedService)) {
(this.sharedService as any)[prop] = null;
Expand Down Expand Up @@ -459,7 +461,7 @@ export class AngularSlickgridComponent<TData = any> implements AfterViewInit, On
}

emptyGridContainerElm() {
const gridContainerId = this.gridOptions?.gridContainerId ?? 'grid1';
const gridContainerId = this.gridOptions?.gridContainerId || 'grid1';
const gridContainerElm = document.querySelector(`#${gridContainerId}`);
emptyElement(gridContainerElm);
}
Expand Down Expand Up @@ -502,7 +504,7 @@ export class AngularSlickgridComponent<TData = any> implements AfterViewInit, On
this._eventPubSubService.publish('onBeforeGridCreate', true);

// make sure the dataset is initialized (if not it will throw an error that it cannot getLength of null)
this._dataset = this._dataset || [];
this._dataset ||= [];
this.gridOptions = this.mergeGridOptions(this.gridOptions);
this._paginationOptions = this.gridOptions?.pagination;
this.locales = this.gridOptions?.locales ?? Constants.locales;
Expand Down
Loading