diff --git a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts index bd02d32fe..b4f28ea45 100644 --- a/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts +++ b/src/app/modules/angular-slickgrid/components/angular-slickgrid.component.ts @@ -624,20 +624,15 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn this.gridEventService.bindOnClick(grid, dataView); if (dataView && grid) { - this._eventHandler.subscribe(dataView.onRowCountChanged, (e: Event, args: any) => { - grid.invalidate(); - - this.metrics = { - startTime: new Date(), - endTime: new Date(), - itemCount: args && args.current || 0, - totalItemCount: Array.isArray(this.dataset) ? this.dataset.length : 0 - }; + // When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty + // we will do that via the following 2 handlers (onSetItemsCalled, onRowCountChanged) + this._eventHandler.subscribe(dataView.onSetItemsCalled, () => { + this.handleOnItemsChanged(this.dataset.length); + }); - // when using local (in-memory) dataset, we'll display a warning message when filtered data is empty - if (this._isLocalGrid && this.gridOptions && this.gridOptions.enableEmptyDataWarningMessage) { - this.displayEmptyDataWarning(args.current === 0); - } + this._eventHandler.subscribe(dataView.onRowCountChanged, (_e: Event, args: any) => { + grid.invalidate(); + this.handleOnItemsChanged(args.current || 0); }); // Tree Data with Pagiantion is not supported, throw an error when user tries to do that @@ -776,6 +771,21 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn } } + /** When data changes in the DataView, we'll refresh the metrics and/or display a warning if the dataset is empty */ + private handleOnItemsChanged(itemCount: number) { + this.metrics = { + startTime: new Date(), + endTime: new Date(), + itemCount: itemCount, + totalItemCount: Array.isArray(this.dataset) ? this.dataset.length : 0 + }; + + // when using local (in-memory) dataset, we'll display a warning message when filtered data is empty + if (this._isLocalGrid && this.gridOptions && this.gridOptions.enableEmptyDataWarningMessage) { + this.displayEmptyDataWarning(itemCount === 0); + } + } + private initializePaginationService(paginationOptions: Pagination) { if (this.gridOptions) { this.paginationData = {