Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow using AureliaSlickgrid component w/o grid options #1298

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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 @@ -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
Loading