1

How to get the rows that are actually in the "Showing Items"? $scope.gridApi.core.getVisibleRows seems to be giving inconsistent values.

http://plnkr.co/edit/FRaCNxKhZ242rFyqNDkm?p=preview

gridApi.core.on.filterChanged($scope, function () {
    $timeout(function () {
        var allvisiblerows = $scope.gridApi.core.getVisibleRows($scope.gridApi.grid);
        $scope.visibleRowsCount = allvisiblerows.length;
    }, 0);
});

enter image description here

RedApple
  • 201
  • 1
  • 5
  • 15

1 Answers1

1

The problem with filterChanged is that it is raised as soon as the filters change but at that time the data has not necessarily been filtered. To fix this, rather than listening to the filterChanged you can listen to rowsRendered event and that will fix the issue.

gridApi.core.on.rowsRendered($scope, function () {
    var allvisiblerows = $scope.gridApi.core.getVisibleRows($scope.gridApi.grid);
    $scope.visibleRowsCount = allvisiblerows.length;
});

This way you can also get rid of the $timeout.

RedApple
  • 201
  • 1
  • 5
  • 15
Guranjan Singh
  • 734
  • 2
  • 7
  • 24