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

Commit 07dbbb1

Browse files
committed
fix(backend): make sure pagination object exist before using it
1 parent 128600e commit 07dbbb1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
326326

327327
// when we have a totalCount use it, else we'll take it from the pagination object
328328
// only update the total items if it's different to avoid refreshing the UI
329-
const totalRecords = totalCount !== undefined ? totalCount : this.gridOptions.pagination.totalItems;
329+
const totalRecords = totalCount !== undefined ? totalCount : (this.gridOptions && this.gridOptions.pagination && this.gridOptions.pagination.totalItems);
330330
if (totalRecords !== this.totalItems) {
331331
this.totalItems = totalRecords;
332332
}
@@ -537,12 +537,13 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
537537
}
538538

539539
// the processes can be Promises or Observables (like Angular HttpClient)
540+
const totalItems = this.gridOptions && this.gridOptions.pagination && this.gridOptions.pagination.totalItems;
540541
if (process instanceof Promise && process.then) {
541-
process.then((processResult: GraphqlResult | any) => executeBackendProcessesCallback(startTime, processResult, backendApi, this.gridOptions.pagination.totalItems))
542+
process.then((processResult: GraphqlResult | any) => executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems))
542543
.catch((error: any) => onBackendError(error, backendApi));
543544
} else if (isObservable(process)) {
544545
process.subscribe(
545-
(processResult: GraphqlResult | any) => executeBackendProcessesCallback(startTime, processResult, backendApi, this.gridOptions.pagination.totalItems),
546+
(processResult: GraphqlResult | any) => executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems),
546547
(error: any) => onBackendError(error, backendApi)
547548
);
548549
}

0 commit comments

Comments
 (0)