Vue Ag-grid Hide/unhide All Columns At Once
I am trying to hide and unhide all columns in ag-grid on data change from the parent component. This is my child component
Solution 1:
setColumnsVisible()
accepts a number as an argument which is a Column.colId
. getAllColumns()
return an array of Column
so you need to use a for-loop here
constshowAllColumn = () => {
const allColumns = columnApi.getAllColumns().forEach((c) => {
columnApi.setColumnVisible(c.getColId(), true);
});
};
consthideAllColumn = () => {
const allColumns = columnApi.getAllColumns().forEach((c) => {
columnApi.setColumnVisible(c.getColId(), false);
});
};
Usage
<buttononClick={showAllColumn}>Show all columns</button><buttononClick={hideAllColumn}>Hide all columns</button>
Post a Comment for "Vue Ag-grid Hide/unhide All Columns At Once"