简体   繁体   English

ag-grid 和最终形式的问题

[英]Issues with ag-grid and final-form

I'm struggling to create an editable grid with ag-grid.我正在努力用 ag-grid 创建一个可编辑的网格。 I've found that using both a renderer and editor where both have useField creates problems when removing rows with react-final-form-array.我发现在使用 react-final-form-array 删除行时,同时使用渲染器编辑器(两者都具有 useField)会产生问题。

Keep in mind that a renderer is the readonly/normal state of the cell while the editor is the edit view;请记住,渲染器是单元格的只读/正常状态,而编辑器是编辑视图; Editor is only rendered while editing.编辑器仅在编辑时呈现。

https://codesandbox.io/s/infallible-violet-joej4?file=/src/App.js https://codesandbox.io/s/infallible-violet-joej4?file=/src/App.js

In the example above, you'll see that I've commented out the renderer and validation rules.在上面的例子中,你会看到我已经注释掉了渲染器和验证规则。 Commenting out the renderer prevents me from displaying validation errors--on top of this, ag-grid destroys the useField, so my validations are also lost.注释掉渲染器会阻止我显示验证错误——除此之外,ag-grid 会破坏 useField,因此我的验证也会丢失。

Naively, I thought form validation instead of field validation was the way to go, but again, I still require a custom renderer to display validations or metadata.天真地,我认为表单验证而不是字段验证是要走的路,但同样,我仍然需要一个自定义渲染器来显示验证或元数据。

I then thought of creating a two dimensional array that has all of the useField cells but this causes "Rendered more hooks than during the previous render."然后我想到创建一个包含所有 useField 单元格的二维数组,但这会导致“渲染的钩子比上一次渲染时更多。” errors.错误。 I'm not well versed in hooks but I don't see <Field> working either.我不精通钩子,但我也没有看到<Field>工作。

Thoughts?想法?

Moved away from updating by cell, and instead updated by grid.不再按单元更新,而是按网格更新。 This let ag-grid be the source of truth that updates final-form as needed.这让 ag-grid 成为根据需要更新最终形式的事实来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM