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?
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.
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.
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.
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.
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;
}
I think this is the simplest answer.
let {rowsToDisplay} = params.api.getModel();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With