Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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. I'm looking for something getAllRows() to return all the rows in the grid. I know there is a way to loop through all the rows using api.forEachNode() etc. Is there any way I can get the entire array of rows?

like image 301
Sandeep Kumar Avatar asked Jun 05 '18 09:06

Sandeep Kumar


People also ask

How do you get row data in ag-grid react?

The easiest way to get a Row Node is by its Row ID. The ID is either provided by you using the grid callback getRowId() , or generated by the grid using an internal sequence.

How do you get modified rows on ag-grid?

Call the method onCellValueChanged, on the event cellValueChanged. Inside the method, add the row id of the row being edited to the set. While submitting the data, iterate through the set of edited row ids and get the row using grid api. Show activity on this post.

How do you get row index on ag-grid?

You can use getVirtualRow() method to get a single row. This function is a part of the Row Model. You can get the Row Model by getModel() function.

How many rows can ag-grid handle?

Here are more detailed rules of thumb. If you are not sure, use default Client-Side. The grid can handle massive amounts of data (100k+ rows). The grid will only render what's visible on the screen (40 rows approximately, depending on your screen size) even if you have thousands of rows returned from your server.


2 Answers

I don't think there is such a method but you can make your own:

getAllRows() {
  let rowData = [];
  this.gridApi.forEachNode(node => rowData.push(node.data));
  return rowData;
}
like image 123
Michael Karén Avatar answered Oct 24 '22 06:10

Michael Karén


I think this is the simplest answer.

let {rowsToDisplay} = params.api.getModel();

like image 7
Steve Kim Avatar answered Oct 24 '22 05:10

Steve Kim