用于检查列是否可见的 Ag 网格

Ag grid to check if column is visible or not

我正在尝试 hide/Show Ag 网格中的列。

下面是我的 hiding/showing 列代码

 this.gridOptions.columnApi.setColumnsVisible(["Col1", "Col2"], true);

 this.gridOptions.columnApi.setColumnsVisible(["Col3", "Col4"], false);

如果列已经隐藏或可见,我如何找到?基于列的当前状态,我需要执行上面的代码。请帮忙

this.gridOptions.columnApi.getColumn("Col1").visible

Source:

getColumn(colKey): Returns the column with the given 'key'. The key can either be the colId (a string) or the colDef (an object).