In my job we decided to use AG-Grid
in react variant: https://www.ag-grid.com/best-react-data-grid/index.php
Currently, our architecture for React
is Redux
. From my little knowledge of AG-Grid
I can say that it doesn't fit very well to this architecture. AG-Grid
keeps it's overall state inside the component. It's cumbersome or even not clever to try to connect it to redux forcefully and completely.
I can live with that but at least I need to watch for the row model changes - meaning fetches of new rows, sorts, filtering (I don't need to watch for cell changes). I have 2 ideas on how to watch for this and connect it to redux.
Option 1 - Use gridOptions.onModelUpdated()
With gridOptions.onModelUpdated()
I know when filtering or sort was executed but I can't get to all rows displayed (docs):
State 1: Row Data
API: There is no API to get this data. However it was provided by the application so you should already have it.
Thus I can't dispatch a redux
action as I don't have any data to update it with.
Option 2 - datasource.getRows()
I could dispatch actions with new rows. However, I haven't found any onReset/onRowsDeleted/...
event, thus I don't know when to clear redux's state.rows
. Update I can know that previous rows were cleared if argumernt params
of datasource.getRows(params)
is params.startRow === 0
.
Question
Maybe I find a way how to use one of the 2 options but my question is:
Are those good ideas to how connect AG-Grid
to Redux
?