5
votes

I am using the follwoing dependencies:

"dependencies": {
   "ag-grid-community": "19.0.0",
   "ag-grid-angular": "19.0.0",
   "ag-grid-enterprise": "19.0.0",
}

After migrating to version 19 the new sidebar was hidden. This could be fixed by setting [sideBar]="'columns'".

But the tool panel section is always open. I could close it by calling gridApi.closeToolPanel(), but in this case you see the open toolPanel for a short moment if you load the page. Is there an option to show only the side bar buttons and hide the toolPanel by default (as it was in version 18)?

3

3 Answers

14
votes
var gridOptions = {    
sideBar: {
    toolPanels: [
            {
                id: 'columns',
                labelDefault: 'Columns',
                labelKey: 'columns',
                iconKey: 'columns',
                toolPanel: 'agColumnsToolPanel',
                toolPanelParams: {
                    suppressValues: true,
                    suppressPivots: true,
                    suppressPivotMode: true,
                    suppressRowGroups: false
                }
            },
            {
                id: 'filters',
                labelDefault: 'Filters',
                labelKey: 'filters',
                iconKey: 'filter',
                toolPanel: 'agFiltersToolPanel',
            }
        ],
        defaultToolPanel: ''
    }
};

The defaultTooPanel: '' is what tells ag-grid what should be opened by default. You can set it to blank or null and that will it cause it to not open any toolPanel by default.

Note: in version 19.0.0, you will get a console.log warning about this. In 19.1.1, you will not get the warning.

6
votes

To keep the ToolPanel closed by default, you need to set the defaultToolPanel to an empty string value.

        sideBar: {
            toolPanels: [
                {
                    id: "columns",
                    labelDefault: "Columns",
                    labelKey: "columns",
                    iconKey: "columns",
                    toolPanel: "agColumnsToolPanel",
                },
                {
                    id: "filters",
                    labelDefault: "Filters",
                    labelKey: "filters",
                    iconKey: "filter",
                    toolPanel: "agFiltersToolPanel",
                },
            ],
            defaultToolPanel: "",
        }

This is as the default value for defaultToolPanel is columns.

1
votes

It depends on exactly where you are calling gridApi.closeToolPanel().

Check this plunk I've created. It's for angular, but I hope you will be able understand.

Call the funciton inside onGridReady.

onGridReady(params) {
  this.gridApi = params.api;
  this.gridApi.closeToolPanel();
}

Another similar kind of question: On upgrade ag-grid version 19 from version 9, on right click tool panel option is not coming.