javascript - AgGrid : applyColumnState is not a function

标签 javascript reactjs ag-grid ag-grid-react

我在我的项目中使用 ag-grid,我在应用表状态时遇到问题。这是我来自 onGridReady 的代码片段功能:

 this.gridApi = params.api;
    this.gridColumnApi = params.columnApi;

    if (!window.colState) {
        console.log("no columns state to restore by, you must save state first");
    } else {
        this.gridColumnApi.applyColumnState({
            state: window.colState,
            applyOrder: true,
        });
        console.log("column state restored");
    }
它当然取自 ag-grid。
在它下面我有this.gridColumnApi.getAllColumns()this.gridColumnApi.autoSizeColumns()功能正常。
问题是 this.gridColumnApi.applyColumnState给我这个错误。
TypeError: _this.gridColumnApi.applyColumnState is not a function
我不明白为什么在 this.gridColumnApi 上调用其他函数有效,但 applyColumnState没有。有什么建议么?
@编辑
我什至试过这个:
componentWillUnmount() {
    window.colState = this.props.gridColumnApi.getColumnState();
    console.log("column state saved");
    if (this.props.gridColumnApi.applyColumnState) {
        devLog("IT IS HERE");
    } else {
        devLog("its not");
    }
    this.gridColumnApi.resetColumnState();
    console.log("column state reset");
}
但我得到 applyColumnStateresetColumnState不是函数错误,这里有什么问题?

最佳答案

检查您的 AgGrid 版本。 ColumnApi.applyColumnState()在版本 24.0.0 中添加.

关于javascript - AgGrid : applyColumnState is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63954071/

相关文章:

export - ag-grid 默认导出选择行

json - 使用 Ag-grid 将 JSON 导出到 excel (csv)

javascript - 是否可以在 AG-Grid 中过滤多个字符串?

javascript - Reactjs shouldComponentUpdate 与函数

reactjs - 如何在微前端架构中共享 redux store?

javascript - 如何增加 Firestore 中的数字?

javascript - React-Redux 与 Formik 连接 - 超出最大调用堆栈大小

node.js - 仅在 NodeJS 和 ExpressJS 中满足条件后才更新密码

javascript - 谷歌浏览器在开发者工具中复制 CSS 路径

javascript - 当我不希望页面重新加载时