AG-GRID 不是 gridApi 上的 applyTransaction 方法 [英] AG-GRID does not an applyTransaction method on gridApi

查看:46
本文介绍了AG-GRID 不是 gridApi 上的 applyTransaction 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 onGridReady() 方法:

onGridReady = (grid) => {
    this.gridInstance = grid;
    this.resizeColumnsToFit();
    this.props.setIsLoading(false);
    this.gridApi = grid.api;
    this.gridColumnApi = grid.columnApi;
    console.log("gridOptions is", this.gridOptions);
};

然后在一个按钮中点击我有:

then in a button click I have:

const sel = this.gridApi.getSelectedRows();
console.log(sel); // this one is good.
const res = this.gridApi.applyTransaction({ remove: sel }); // this one is not good

但我收到此错误:

Uncaught (in promise) TypeError: _this.gridApi.applyTransaction is not a function

我试图从这里遵循他们自己的例子:https://www.ag-grid.com/react-data-grid/data-update-transactions/

I tried to follow their own example from here: https://www.ag-grid.com/react-data-grid/data-update-transactions/

那我做错了什么?

推荐答案

applyTransaction

检查 sel 是否存在然后:-

check sel exists then:-

this.gridApi?.applyTransaction({ remove: sel });

低于23.1.0的版本,使用

version lower than 23.1.0, use

this.gridApi?.updateRowData({ remove: sel })

https://www.ag-grid.com/ag-grid-changelog/?fixVersion=23.1.0

这篇关于AG-GRID 不是 gridApi 上的 applyTransaction 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆