在 ag-grid 中隐藏按钮单击的列?

Hide columns on button click in ag-grid?

我需要在单击按钮时隐藏 VAD 组列。请帮我。

您可以使用 Column API 方法:

setColumnVisible(colKey, visible) Sets the visibility of a column. Key can be the column id or Column object.

setColumnsVisible(colKeys, visible) Same as setColumnVisible, but provide a list of column keys.

hide(){
    this.gridColumnApi.setColumnsVisible(['columnNameOne', 'columnNameTwo'], false);
}

show(){
    this.gridColumnApi.setColumnsVisible(['columnNameOne', 'columnNameTwo'], true);
}

Demo