当前位置 : 主页 > 网页制作 > React >

reactjs – AG-Grid with Redux

来源:互联网 收集:自由互联 发布时间:2021-06-15
在我的工作中,我们决定在反应变量中使用AG-Grid: https://www.ag-grid.com/best-react-data-grid/index.php 目前,我们的React架构是Redux.根据我对AG-Grid的一点知识,我可以说它不适合这种架构. AG-Grid保持
在我的工作中,我们决定在反应变量中使用AG-Grid: https://www.ag-grid.com/best-react-data-grid/index.php

目前,我们的React架构是Redux.根据我对AG-Grid的一点知识,我可以说它不适合这种架构. AG-Grid保持组件内部的整体状态.尝试将其与redux强有力地完全连接起来很麻烦甚至不聪明.

我可以忍受这一点,但至少我需要注意行模型的更改 – 意味着获取新行,排序,过滤(我不需要注意单元格更改).我有2个想法如何观察并将其连接到redux.

选项1 – 使用gridOptions.onModelUpdated()

使用gridOptions.onModelUpdated()我知道当执行过滤或排序但我无法访问所有显示的行(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.

因此,我无法发送redux操作,因为我没有任何数据来更新它.

选项2 – datasource.getRows()

我可以用新行调度动作.但是,我还没有找到任何onReset / onRowsDeleted / …事件,因此我不知道何时清除redux的state.rows.更新我可以知道如果datasource.getRows(params)的参数params是params.startRow === 0,则前面的行被清除.

也许我找到了如何使用2个选项之一的方法,但我的问题是:

那些将AG-Grid连接到Redux的好主意是什么?

Ag-grid(v10.1.0)现在支持Redux:

https://ag-grid.com/example-react-redux/?framework=all#gsc.tab=0

网友评论