Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 706
TerribleDeveloper Avatar asked Dec 10 '18 13:12

TerribleDeveloper


2 Answers

suppressContextMenu:true for gridOptions

Will work

like image 55
LazyDeveloper Avatar answered Oct 20 '22 11:10

LazyDeveloper


[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.

like image 4
Paritosh Avatar answered Oct 20 '22 10:10

Paritosh