How to get the selected row-data at contextMenuClick?

How to get the selected row-data at the event contextMenuClick?
In JS1 there is a property "rowData" in the argument, but in EJ2 this property seems not available.



1 Reply

PS Pavithra Subramaniyam Syncfusion Team July 14, 2018 01:51 PM UTC

Hi Sietse, 

We have checked your query and You can achieve your requirement by using following workaround. We have prepared a simple sample based on your query in which we have get the row data by using getRowObjectFromUID() method. Please refer to the below code example , Documentation link and sample link. 

[component.ts] 
@Component({ 
    selector: 'app-container', 
    template: `<ejs-grid #grid [dataSource]='data'(contextMenuClick)='click($event)' id="gridcomp" allowPaging='true' [allowExcelExport]='true' [allowPdfExport]='true' height='220px' [allowSorting]='true' 
        [contextMenuItems]="contextMenuItems" [editSettings]='editing' [allowGrouping]='true'> 
       .   .   . 
    </ejs-grid> 
                `, 
    providers: [ContextMenuService, PageService, ResizeService, SortService, GroupService, EditService, PdfExportService, ExcelExportService ] 
}) 
export class AppComponent implements OnInit { 
    .   .   . 
    ngOnInit(): void { 
        this.data = data; 
    } 
    click(e:any){ 
     var rowObj = this.grid.getRowObjectFromUID(this.grid.getSelectedRows()[0].getAttribute('data-uid')) 
     alert(rowObj.data.OrderID); 
    } 

                               https://ej2.syncfusion.com/angular/documentation/grid/api-gridComponent.html#contextmenuclick  

Sample               : https://plnkr.co/edit/pM8GBrdV8JA20oZqWavH?p=preview  

Regards, 
Pavithra S. 


Loader.
Up arrow icon