如何禁用Ag-Grid的右键单击/上下文菜单?

时间:2018-12-10 13:35:10

标签: ag-grid ag-grid-angular

我使用的是ag-grid企业版,我想禁用上下文菜单或右键单击网格单元,但未找到任何解决方案。

这是我的代码

<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

2 个答案:

答案 0 :(得分:3)

suppressContextMenu:true for gridOptions

会工作

答案 1 :(得分:2)

[suppressContextMenu]="true"会问您。

或者,如果要在组件中定义getContextMenuItems,只需从函数中返回空数组。

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

看看this plunk I've created

您还可以有条件地决定是否对任何特定列都不希望使用它,或者不使用参数params