1

Previously, I have used this.gridApi.getDisplayedRowCount(). However, I recently implemented a Master/Detail record structure for one of my grids and I have found that getDisplayedRowCount() is counting the children Detail records as displayed rows.

For example, if I have a table that contains 10 rows, then this.gridApi.getDisplayedRowCount() would return 10. Displaying the Details for one of the rows increases that return value to 11.

This isn't behavior that I want, so is there a way to just get the displayed rows, excluding detail rows?

Looking through the gridApi object, I have found a way to do it, but I don't really like that I am accessing nested objects without using the provided API.

this.gridApi.rowModel.rowsToDisplay.filter(row => !row.detail).length; -> 10

Rich
  • 1,567
  • 14
  • 24

1 Answers1

1

gridApi.forEachNode() and gridApi.forEachNodeAfterFilter() both appear to skip detail rows while iterating thru row data, so for now, this is the approach that I am following to get this data.

I have replaced my gridApi call to get the displayed row count with a custom function to count the nodes we visit using forEachNodeAfterFilter..

  getDisplayedRowCount(){
    let count = 0;
    this.gridApi.forEachNodeAfterFilter(() => count++);
    return count;
  }
Rich
  • 1,567
  • 14
  • 24