ng-grid get filtered column count after filtering
- by Ryan Langton
I'm using ng-grid with filtering. Any time the filter updates I want to get the filtered item count. I have been able to do this using the filteredRows property of ngGrid. However I'm getting the rows BEFORE the filtering occurs and I want them AFTER the filtering occurs. Here is a plunker to demonstrate the behavior: http://plnkr.co/edit/onyE9e?p=preview
Here is the code where filtering is occuring:
$scope.$watch('gridOptions.filterOptions.filterText2', function(searchText, oldsearchText) {
if (searchText !== oldsearchText) {
$scope.gridOptions.filterOptions.filterText = "name:" + searchText + "; ";
$scope.recordCount = $scope.gridOptions.ngGrid.filteredRows.length;
}
});