Skip to content

Commit

Permalink
feat: allow using AureliaSlickgrid component w/o grid options (#1298)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Dec 11, 2024
1 parent b59bf34 commit 0345ecd
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class AureliaSlickgridCustomElement {
@bindable() dataset: any[] = [];
@bindable() datasetHierarchical?: any[] | null;
@bindable() gridId = '';
@bindable() gridOptions!: GridOption;
@bindable() gridOptions: GridOption = {};

constructor(
protected readonly aureliaUtilService: AureliaUtilService = resolve(AureliaUtilService),
Expand Down Expand Up @@ -248,8 +248,8 @@ export class AureliaSlickgridCustomElement {
}

attached() {
if (!this.gridOptions || !this.columnDefinitions) {
throw new Error('Using `<aurelia-slickgrid>` requires `grid-options.bind` and `column-definitions.bind`, it seems that you might have forgot to provide them since at least of them is undefined.');
if (!this.columnDefinitions) {
throw new Error('Using `<aurelia-slickgrid>` requires `column-definitions.bind`, it seems that you might have forgot to provide the missing bindable model.');
}

this._eventHandler = new SlickEventHandler();
Expand Down Expand Up @@ -291,7 +291,7 @@ export class AureliaSlickgridCustomElement {
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._dataset ||= [];
this._currentDatasetLength = this._dataset.length;
this.gridOptions = this.mergeGridOptions(this.gridOptions);
this._paginationOptions = this.gridOptions?.pagination;
Expand Down Expand Up @@ -556,7 +556,7 @@ export class AureliaSlickgridCustomElement {
}

emptyGridContainerElm() {
const gridContainerId = this.gridOptions?.gridContainerId ?? 'grid1';
const gridContainerId = this.gridOptions?.gridContainerId || 'grid1';
const gridContainerElm = document.querySelector(`#${gridContainerId}`) as HTMLDivElement;
emptyElement(gridContainerElm);
}
Expand Down

0 comments on commit 0345ecd

Please sign in to comment.