How can I disable or hide context menu from a particular column of angular ag-grid

Asked
Active3 hr before
Viewed126 times

5 Answers

angularparticularcolumncontext
90%

Hiding the Context Menu,Configuring the Context Menu,If you want to turn off the context menu completely, set the grid property suppressContextMenu=true,,Open the context menu or the column menu in the grid

Example_snippet/controller/utility/_angular.js/ GetContextMenuItemsParams { . . .
GetContextMenuItemsParams {
   column: Column, // the column that was clicked
   node: RowNode, // the node that was clicked
   value: any, // the value displayed in the clicked cell
   api: GridApi, // the grid API
   columnApi: ColumnAPI, // the column API
   context: any, // the grid context
   defaultItems: string[] | undefined // names of the items that would be provided by default
}
load more v
88%

Example_snippet/controller/utility/_angular.js/ this.gridOptions.suppressNoRow. . .
this.gridOptions.suppressNoRowsOverlay = true;
this.service.getData()
   .subscribe(data => {
         if (!data || !data.length) {
            this.gridOptions.suppressNoRowsOverlay = false;
            this.gridOptions.api.showNoRowsOverlay();
         }
load more v
72%

Context menu with specific options,You can define items in the menu by passing the contextMenu option as an array of keys which are strings:,Context menu with default options,Context menu with fully custom configuration

Example_snippet/controller/utility/_angular.js/ const container = document.que. . .
const container = document.querySelector('#example1');

const hot = new Handsontable(container, {
   data: [
      ['', 'Tesla', 'Nissan', 'Toyota', 'Honda', 'Mazda', 'Ford'],
      ['2017', 10, 11, 12, 13, 15, 16],
      ['2018', 10, 11, 12, 13, 15, 16],
      ['2019', 10, 11, 12, 13, 15, 16],
      ['2020', 10, 11, 12, 13, 15, 16],
      ['2021', 10, 11, 12, 13, 15, 16]
   ],
   rowHeaders: true,
   colHeaders: true,
   contextMenu: true,
   height: 'auto',
   licenseKey: 'non-commercial-and-evaluation'
});
load more v
65%

If filtering is enabled, the filter item is displayed for columns with fields by default, To add the filter item without the need to enable filtering, use the filter option of the column menu

Example_snippet/controller/utility/_particular.js/ Copy Code <kendo-grid . . .
Copy Code < kendo - grid[columnMenu] = "{
filter: {
      expanded: true
   },
   stick: true,
   lock: true,
   setColumnPosition: {
      expanded: true
   }
}
"
75%

I have angular ag-grid and needed to display the context menus in grid but do not want to show context menu in a particular column,,there is not any such property to hide from column

Example_snippet/controller/utility/_particular.js/ getContextMenuItems(params) { . . .
getContextMenuItems(params) {

   if (params.column.colId == "columnToDisable") {
      return [];
   } else {
      // otherwise return array of context menu items
   }
}