Search code examples
vuejs2multiple-columnshideag-gridshow

Do not show some columns in the agColumnsToolPanel


How could I prevent the agColumnsToolPanel from showing specific columns?

E.g. I would like to not show entries for the foo and bar, but only for the x, meaning that it would be impossible to change the foo, bar columns visibility through the agColumnsToolPanel.

enter image description here

I am using the Ag Grid with Vue.js.


Solution

  • This example shows you have to update the columns in the tool panel.

    Relevant code is as follows. Get a reference to the column tool panel and then set the columns to be just your column definitions for foo and bar.

        setCustomCols() {
          var columnToolPanel = this.gridApi.getToolPanelInstance('columns');
          columnToolPanel.setColumnLayout([{field: 'foo'}]}, {field: 'bar'});
        },