Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To integrate Redux with Ag-Grid's server-side row model in React, you can follow these steps:

  1. Define your Redux store and actions for handling the data that will be displayed in the grid.

  2. Create a Redux-connected component that will contain the Ag-Grid component.

  3. In this component, define a method to fetch the initial data to be displayed in the grid. This method should be called once the component has mounted. The data can be fetched using a Redux action that populates the store with the initial data.

  4. In the Ag-Grid component, set the rowModelType prop to 'serverSide' and provide a server-side row model parameters object that includes the row data URL and any other required parameters.

  5. Define a onGridReady callback function in the server-side row model parameters object that will be called once the grid is constructed. This function should dispatch a Redux action that will fetch the first page of data from the server and populate the store with it.

  6. Define a onGridPagedChanged callback function in the server-side row model parameters object that will be called whenever the user navigates to a different page. This function should dispatch a Redux action that fetches the corresponding page of data from the server and updates the store with it.

  7. For each column, define a cellRenderer function that retrieves the data for that cell from the store.

  8. Render the Ag-Grid component in your Redux-connected component, passing in any required props such as column definitions and pagination settings.

  9. When the user interacts with the grid, such as by changing the page or sorting, the onGridPagedChanged and onSortChanged callbacks will be fired. These callbacks should dispatch the corresponding Redux actions to update the store and fetch the new data.

By following these steps, you can integrate Redux with Ag-Grid's server-side row model in React to manage the data displayed in the grid.