AG-GRID 没有 gridApi 上的 applyTransaction 方法
AG-GRID does not an applyTransaction method on gridApi
这是我的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);
};
然后在一个按钮中点击我有:
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/
那我做错了什么?
applyTransaction
需要版本 23.1.0
检查 sel
是否存在:-
this.gridApi?.applyTransaction({ remove: sel });
版本低于23.1.0,使用
this.gridApi?.updateRowData({ remove: sel })
https://www.ag-grid.com/ag-grid-changelog/?fixVersion=23.1.0
这是我的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);
};
然后在一个按钮中点击我有:
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/
那我做错了什么?
applyTransaction
检查 sel
是否存在:-
this.gridApi?.applyTransaction({ remove: sel });
版本低于23.1.0,使用
this.gridApi?.updateRowData({ remove: sel })
https://www.ag-grid.com/ag-grid-changelog/?fixVersion=23.1.0