@@ -624,20 +624,15 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
624
624
this . gridEventService . bindOnClick ( grid , dataView ) ;
625
625
626
626
if ( dataView && grid ) {
627
- this . _eventHandler . subscribe ( dataView . onRowCountChanged , ( e : Event , args : any ) => {
628
- grid . invalidate ( ) ;
629
-
630
- this . metrics = {
631
- startTime : new Date ( ) ,
632
- endTime : new Date ( ) ,
633
- itemCount : args && args . current || 0 ,
634
- totalItemCount : Array . isArray ( this . dataset ) ? this . dataset . length : 0
635
- } ;
627
+ // When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty
628
+ // we will do that via the following 2 handlers (onSetItemsCalled, onRowCountChanged)
629
+ this . _eventHandler . subscribe ( dataView . onSetItemsCalled , ( ) => {
630
+ this . handleOnItemsChanged ( this . dataset . length ) ;
631
+ } ) ;
636
632
637
- // when using local (in-memory) dataset, we'll display a warning message when filtered data is empty
638
- if ( this . _isLocalGrid && this . gridOptions && this . gridOptions . enableEmptyDataWarningMessage ) {
639
- this . displayEmptyDataWarning ( args . current === 0 ) ;
640
- }
633
+ this . _eventHandler . subscribe ( dataView . onRowCountChanged , ( _e : Event , args : any ) => {
634
+ grid . invalidate ( ) ;
635
+ this . handleOnItemsChanged ( args . current || 0 ) ;
641
636
} ) ;
642
637
643
638
// 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
776
771
}
777
772
}
778
773
774
+ /** When data changes in the DataView, we'll refresh the metrics and/or display a warning if the dataset is empty */
775
+ private handleOnItemsChanged ( itemCount : number ) {
776
+ this . metrics = {
777
+ startTime : new Date ( ) ,
778
+ endTime : new Date ( ) ,
779
+ itemCount : itemCount ,
780
+ totalItemCount : Array . isArray ( this . dataset ) ? this . dataset . length : 0
781
+ } ;
782
+
783
+ // when using local (in-memory) dataset, we'll display a warning message when filtered data is empty
784
+ if ( this . _isLocalGrid && this . gridOptions && this . gridOptions . enableEmptyDataWarningMessage ) {
785
+ this . displayEmptyDataWarning ( itemCount === 0 ) ;
786
+ }
787
+ }
788
+
779
789
private initializePaginationService ( paginationOptions : Pagination ) {
780
790
if ( this . gridOptions ) {
781
791
this . paginationData = {
0 commit comments