Ayesha Khan
Ayesha Khan

Reputation: 125

How to get the number of filtered rows in ag-grid without using in memory row model?

I am using ag-grid to display data. There are two tabs for current data and archived data. Above the grid for both tabs, in the title bar, there is a filter that filters the free text. The label of that filter shows the filtered rows/total number of rows. In the archived tab, there is an additional filter that selects the data from past months. The filtered row count gets bigger than the actual number of rows when you quickly switch to:

I think it is the in memory row model that is causing this issue. I tried these two to get filtered rows this.selectedRows = this.gridOptions.api.getModel().getRowCount();

this.selectedRows = this.gridOptions.api.getModel().rootNode.childrenAfterFilter.length;

I was just wondering is there any other way of doing it without using the in memory row model. Any help would be greatly appreciated. Thanks a lot.

Upvotes: 2

Views: 2576

Answers (1)

Ayesha Khan
Ayesha Khan

Reputation: 125

For future reference: The code below is fine.

this.selectedRows = this.gridOptions.api.getModel().getRowCount();

The were some timing issues and I fixed this with resetting the row data by

this.gridOptions.api.setRowData([]);
this.gridOptions.api.setRowData(data);

Upvotes: 1

Related Questions