We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

ejGrid with custom context menu item: How to get the target row (i.e. primary key) in contextClick event handler function?

Setup: ejGrid with custom context menu item

How to get the target row (i.e. primary key) in contextClick event handler function?

Please advise.

3 Replies

JK Jayaprakash Kamaraj Syncfusion Team June 29, 2017 03:19 PM UTC

Hi Thomas, 

Thank you for contacting Syncfusion support. 

We have achieved your requirement using contextOpen and contextClick event of ejGrid. In contextOpen event, we need to store current target row data in global variable and then we can get the primaryKey value in contextClick event using that gloabal variable. Please refer to the below help document and code example. 


<ej-grid id="Grid" [dataSource]="gridData" [editSettings]="editSettings" (contextOpen)="contextopen($event)" allowSorting="true" (contextClick)="contextclick($event)" [contextMenuSettings]="contextSettings" [toolbarSettings]="toolbarSettings"> 
    <e-columns> 
        <e-column field="EmployeeID" [isPrimaryKey]="true"></e-column> 
        <e-column field="FirstName" [editType]= "editType" [dataSource]="data1" ></e-column> 
        <e-column field="LastName" [allowEditing]="false"></e-column> 
    </e-columns> 
</ej-grid> 
export class GridComponent { 
    public gridData: any; 
       public data1 : any; 
    public pagesize: number; 
       public targetRowData : any; 
       contextopen(e){ 
    this.targetRowData = e.model.currentViewData[e.rowIndex]         
    } 
       contextclick(e){ 
       if(!ej.isNullOrUndefined(this.targetRowData)) 
       console.log(this.targetRowData.EmployeeID); 
       } 

Regards, 

Jayaprakash K. 
 



TW Thomas Wittwer June 29, 2017 06:47 PM UTC

Thank you for your support.

Regards

Thomas



JK Jayaprakash Kamaraj Syncfusion Team June 30, 2017 07:31 AM UTC

Hi Thomas,  
 
Thanks for the update. 
 
Please get back to us if you need any further assistance.   
 
Regards,  
 
Jayaprakash K. 


Loader.
Live Chat Icon For mobile
Up arrow icon