简体   繁体   中英

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM