不幸的是,我不能分享代码,因为它是公司机密,但我基本上是使用colDefs来定义我的列在一个反应农业网格中,并希望有一个列,它的单元格都是我构建的自定义JSX按钮组件,它将允许我删除所单击的单元格的行,以及在代码中的其他地方传播更改。我一直在尝试使用cellRenderers,根本不知道如何将自定义的react功能组件添加到单元中。如果有人能对此提供帮助,我们将不胜感激。我将尝试提供所需的尽可能多的附加上下文,但不幸的是无法共享直接代码片段。谢谢!
发布于 2020-12-31 00:17:54
您可以在ag-grid的documentation here中看到一个示例。我还提供了一个sandbox,您可以在其中通过单击每个相应的按钮来从网格中删除行。
基本上,你必须:
- `props.context`, the grid's context which will contain the method(s) to fire in the `onClick` method
- `props.data`, which contains the data for that row - the specific item in the `rowData` array that is.
<AgGridReact />
组件的组件并导入渲染器。frameworkComponents
属性中声明渲染器,如下所示:const handleDelete = (data) => { //您的逻辑在这里};// ...
const colDef = //... { headerName:"delete“cellRenderer:"deleteCellRenderer”},//...;
或者,如果您使用<AgGridColumn>
组件作为子组件:
//...
https://stackoverflow.com/questions/65512960
复制相似问题