Hi Benjamim,
Greetings from Syncfusion support.
Based on your requirement, you want to customize the context menu items based on a condition. Your requirement can be achieved using the `contextMenuOpen` event of the EJ2 Grid. Where you can manage showing and hiding the context menu items dynamically based on some conditions.
Kindly refer the below code example.
[app.component.html]
ejs-grid [dataSource]='data' id="gridcomp" allowPaging='true' allowExcelExport='true' (contextMenuOpen)='contextMenuOpen($event)' allowPdfExport='true' allowSorting='true'
[contextMenuItems]="contextMenuItems" [editSettings]='editing'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right' isPrimaryKey='true'></e-column>
. . .
</ejs-grid>
[app.component.ts]
. . .
contextMenuOpen(args): void {
if(args.rowInfo.rowData.OrderID === 10248) {
args.element.ej2_instances[0].hideItems(['Copy']);
} else {
args.element.ej2_instances[0].showItems(['Copy']);
}
} |
In the above code example , we can hide the copy option when the row has OrderID value is 10248 while opening the context-menu. Please find the sample for your reference.
Please get back to us for further details.
Regards,
J Mohammed Farook