How to to pass the master field ID to the detail form automatically

Hello,

I have a Master detail form that works well except that when adding a new record to the detail form the foreign key value from the master form did not automatically fill in the details field.

How do you overcome this (e.g. to pass the master field ID to the detail form automatically?)


Thank

Sao




1 Reply

NP Naveen Palanivel Syncfusion Team September 20, 2022 02:29 AM UTC

Hi Sao,


Greetings from Syncfusion support


Query:” To pass the master field ID to the detail form automatically”


We checked your Query and we prepared sample as per the requirement To pass the Master Field Id to the detail from when adding new records. We attached the sample in this ticket. Please refer the attached sample and snippet code for reference.


Reference: https://blazor.syncfusion.com/documentation/datagrid/editing#default-column-values-on-adding-new-record


<SfGrid DataSource="@Employees">

    <GridTemplates>

        <DetailTemplate>

            @{

                var employee = (context as EmployeeData);

            }

            <SfGrid  DataSource="@Orders"  Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" AllowPaging="true" >

                     <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>

                 

                    <GridColumns>

                        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" DefaultValue="@employee.EmployeeID" TextAlign="TextAlign.Right" Width="110"> </GridColumn>

                        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer ID" Width="110"></GridColumn>



Please let us know if you have any concerns.


Regards,

Naveen Palanivel



Attachment: MasterGrid_53bc22ed.zip

Loader.
Up arrow icon