Search code examples
reactjsag-gridag-grid-angularag-grid-reactag-grid-vue

AG-GRID forEachNode only operates on a limited number of buffered rows


If I add a console.log() to my code below, I can see that it is correctly printing all of the rows in the gird, I can expand them in developer console and see the data is there.

this.gridApi.forEachNode((rowNode, index) => {
    rowNode.setSelected(false);
});

however, this exact code when I am telling it to do rowNode.setSelected(false); , it only operates on the limited number of rows around 20 or so which is the default rowBuffer on the grid. If the data is there because I can see it with a console.log, then why it cannot delete all the rows? It only deletes the buffered ones.


Solution

  • To select all rows and delete all selected rows:-

     deletedAllSelectedRows() {
              this.gridApi.selectAll(); //select all rows
              const sel = this.gridApi.getSelectedRows();
              this.gridApi.applyTransaction({remove: sel});
          }
    

    Note:- version 23.1.0 is required for applyTransaction. For lower version use updateRowData()