Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the filtered rows in ui-grid?

Using ui-grid I want to get a list of all the filtered data rows using the filter.

In the plunker below I have the original data of 500 items filtered down to 61. Now how do I get a list of those 61 entities?

plnkr link

If I use the following code I only get the rows rendered on the screen

var _renderedRows = $scope.gridApi.grid.renderContainers.body.renderedRows;

Clicking the button at the bottom of that plunker shows the number of filtered rows which is only 14 as opposed to 61. That works perfectly if there are 14 or less in my filter as I can access the entity object from the above. But I can't see any property in the grid that exposes the filtered rows.

So how can I get the list of 61 so I can pass them into another function to perform actions on them?

like image 310
DeclanMcD Avatar asked May 09 '15 12:05

DeclanMcD


1 Answers

Use the PublicApi to get the current visible rows count

$scope.filteredRows = $scope.gridApi.core.getVisibleRows($scope.gridApi.grid);

Here is the updated plnkr (Hint: You have to click the "Get filtered rows" button)

like image 144
kachhalimbu Avatar answered Oct 07 '22 22:10

kachhalimbu