How can I get all the rows of ag-grid?

前端 未结 4 1399
名媛妹妹
名媛妹妹 2021-02-19 09:57

ag-grid provides a way to get selected rows using api.getSelectedRows() function. And provides a way to set all rows using api.setRowData([]) function.

4条回答
  •  無奈伤痛
    2021-02-19 10:47

    I was wondering the same thing and found it annoying that you cannot simply get all rows. In my case I needed to flip a flag on all rows, where the indicator is set outside the component containing the grid, so I did the following. This is in TypeScript for a React app.

      gridApi!.selectAll();
      const rows = gridApi!.getSelectedRows();
    
      rows.forEach(row => {
        row.coverageAction = this.props.isIndicatorChecked;
      });
    
      gridApi!.setRowData(rows);
    

提交回复
热议问题