TerribleDeveloper
TerribleDeveloper

Reputation: 583

How can I disable right click/context menu for ag-grid?

I am using ag-grid enterprise version and I want to disable context menu or a right click on the grid cells but I did not found any solution.

Here is my code

<ag-grid-angular #agGrid style="width: 100%; height: 100%;" id="myGrid" 
[rowData]="rowData" class="ag-theme-balham" [columnDefs]="columnDefs" 
[enableRangeSelection]="true" (gridReady)="onGridReady($event)"></ag-grid- 
angular>

enter image description here

Upvotes: 8

Views: 25220

Answers (2)

Paritosh
Paritosh

Reputation: 11570

[suppressContextMenu]="true" would do your ask.

Alternatively, if you are defining getContextMenuItems in your component, simply return empty array from the function.

this.getContextMenuItems = function getContextMenuItems(params) {
  return [];
};
<ag-grid-angular
    #agGrid
    .........
    [getContextMenuItems]="getContextMenuItems"   // provide the function here
    (gridReady)="onGridReady($event)"
    ></ag-grid-angular>

Have a look at this plunk I've created

You can also conditionally decide if you don't want it for any specific column or not using the arguments params.

Upvotes: 4

LazyDeveloper
LazyDeveloper

Reputation: 619

suppressContextMenu:true for gridOptions

Will work

Upvotes: 19

Related Questions