Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  28] [ 5]  / answers: 1 / hits: 9705  / 4 Years ago, fri, september 18, 2020, 12:00:00

I am using ag-grid in my project and I have problem with applying state of table. Here is my code fragment from onGridReady function:


 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");
}

It is taken from ag-grid of course.
Right under it I have
this.gridColumnApi.getAllColumns()
and this.gridColumnApi.autoSizeColumns()
functions that works fine.


The problem is that this.gridColumnApi.applyColumnState gives me this error.


TypeError: _this.gridColumnApi.applyColumnState is not a function

I cannot understand why other functions called on this.gridColumnApi works but applyColumnState doesn't. Any suggestions?


@edit
I even tried this one:


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");
}

but I get applyColumnState and resetColumnState is not a function errors, what is wrong here?


More From » reactjs

 Answers
0

Check your AgGrid version. ColumnApi.applyColumnState() was added in version 24.0.0.


[#2658] Monday, September 14, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dominics

Total Points: 424
Total Questions: 99
Total Answers: 107

Location: South Korea
Member since Fri, Sep 11, 2020
4 Years ago
;