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.
api.getSelectedRows()
api.setRowData([])
This is how I get the rowData from the grid API:
api.getModel().gridOptionsWrapper.gridOptions.rowData
Lots of methods include gridOptionsWrapper in their return object, so you don't necessarily have to use getModel().
gridOptionsWrapper
getModel()