Get Primary key from Parent Grid

Hi, can i know how to get primary key from parent grid to the child grid (without using Params method). for example, when the user click the button add at the child grid, the custom dialog template already show primary key from parent grid. Thank you.
I hope you can reply as soon as possible (Urgent).

5 Replies

BS Balaji Sekar Syncfusion Team April 20, 2020 02:08 PM UTC

Hi Muhamad Adam, 
 
Greetings from the Syncfusion support, 
 
We have analyzed your query that we cannot understand. Since you expected the parent grid primaryKey column to the child grid when adding a new record even though you said that "custom dialog template already show primary key from the parent grid." Please provide more information about your exact requirement that will help to validate further. 
 
Regards, 
Balaji Sekar 



MA Muhamad Adam Fakhrullah Nik Mohamad April 20, 2020 03:02 PM UTC

I mean when we click the add button, we can get primary key from the parent grid without click save. How to do that sir?



BS Balaji Sekar Syncfusion Team April 21, 2020 02:19 PM UTC

Hi Muhamad Adam, 
 
As per your query, we can access the parent Grid primaryKeyField in the child Grid while add a new record using actionBegin event with requestType in add. Please refer the below code example for more information 
 
[Index.cshtml] 
 
<div> 
    <ejs-grid id="Grid" dataSource="@ViewBag.dataSource" childGrid="childGrid"> 
      <e-grid-columns> 
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" width="150"></e-grid-column> 
          ... 
     </e-grid-columns> 
    </ejs-grid> 
</div> 
 
Var childGrid = new ej.grids.Grid({ 
           .                .               .         .      
         actionBegin: function (args){               
              if(args.requestType == "add"){ 
                var parentGridPkField = this.parentDetails.parentKeyField; 
              }               
            }, 
  .                 .                 .               
}) 
 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Balaji Sekar 



MA Muhamad Adam Fakhrullah Nik Mohamad April 21, 2020 07:06 PM UTC

Thank you very much sir. Its working perfectly.


BS Balaji Sekar Syncfusion Team April 22, 2020 07:41 AM UTC

Hi Muhamad Adam, 
  
We glad that your issue has been fixed.  
  
Please get back to us if you require further other assistance from us. 
  
Regards, 
Balaji Sekar. 


Loader.
Up arrow icon