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

Child Grid with CRUD & Dropdown

hello,
using the childgrid field of new HierarchyGrids in ej2 how can I implement CRUD in the childgrid? also what if i have a dropdownlist as one of the fields in the child grid, how is this done?
In parent Grid, foreign keys are handled like so:  
headertext="Produce Group" 
foreignkeyfield="Id" 
allowediting="true" 
foreignkeyvalue="Name" 
width="165" 
  datasource="@gen.GetLkProduceGroups()">


How can I do this in the Child Grid.

Thanks

5 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team April 11, 2019 01:40 PM UTC

Hi Yoab, 

Greetings from Syncfusion support. 

Based on your query we suspect that you want to know how to enable CRUD configuration for child Grid and set foreignKey column for child Grid. There is no difference to set foreignKey column and enable CRUD operation with child Grid as you given in normal. 

Refer the help documentation. 



Please let us know if you need further assistance on this.  

Regards, 
Thavasianand S. 



YY Yoab Youssoufou April 11, 2019 01:46 PM UTC

Hello I'm afraid you didn't quite understand me. I am talking about the childgrid using the new specification in the master grid(childGrid="ChildGrid1")
the childgrid is then specified as something like:

@{

    var ChildGrid1 = new Syncfusion.EJ2.Grids.Grid()
    {
        DataSource = @pb.GetAll(),
        QueryString = "PayeesId",

        Columns = new List<Syncfusion.EJ2.Grids.GridColumn> {
        new Syncfusion.EJ2.Grids.GridColumn(){ Field="BanksId", HeaderText="Bank", Width="200" },
        new Syncfusion.EJ2.Grids.GridColumn(){ Field="AccountNo", HeaderText="Account No.", Width="70", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right }

}

    };


    };

In this case foreign key in the above child grid cannot be specified as in the mastergrid neither can the CRUD


TS Thavasianand Sankaranarayanan Syncfusion Team April 12, 2019 11:28 AM UTC

Hi Yoab, 

Thanks for your clarification. 

As per your suggestion we have created a sample with foreign key column and editing feature in child Grid. Please refer the below code example and sample for more information. 

 
@{ 
            var ChildGrid1 = new Syncfusion.EJ2.Grids.Grid() 
            { 
                DataSource = ViewBag.empData, 
                QueryString = "EmployeeID", 
                EditSettings = new Syncfusion.EJ2.Grids.GridEditSettings() { AllowAdding = true, AllowEditing = true, AllowDeleting = true }, 
                Toolbar = new List<string>() { "Add", "Edit", "Delete", "Update", "Delete" }, 
                Aggregates = new List<Syncfusion.EJ2.Grids.GridAggregate> { 
            new Syncfusion.EJ2.Grids.GridAggregate() {Columns =col} }, 
                Columns = new List<Syncfusion.EJ2.Grids.GridColumn> { 
new Syncfusion.EJ2.Grids.GridColumn(){ Field="orderid", HeaderText="ID", IsPrimaryKey=true, Width="200" }, 
new Syncfusion.EJ2.Grids.GridColumn(){ Field="id", ForeignKeyField="EmployeeID1", ForeignKeyValue="FullName", DataSource= ViewBag.empData1, HeaderText="Full Name", Width="200" }, 
} 
 
            }; 
        } 
 
============================================= 
 
<ejs-grid id="PublishedGrid" dataSource="ViewBag.data" childGrid="ChildGrid1" allowPaging="true" gridLines="Both"> 
    <e-grid-pagesettings pageSize="10"></e-grid-pagesettings> 
    <e-grid-editSettings allowAdding="false" allowDeleting="false" allowEditing="false" showDeleteConfirmDialog="true" showConfirmDialog="true"></e-grid-editSettings> 
    <e-grid-textwrapsettings wrapMode="Both"></e-grid-textwrapsettings> 
 
    <e-grid-columns> 
        <e-grid-column field="OrderID" isIdentity="true" isPrimaryKey="true" width="180" textAlign="Right" visible="true"></e-grid-column> 
        <e-grid-column field="EmployeeID" headertext="HReadable" width="150"></e-grid-column> 
    </e-grid-columns> 
</ejs-grid> 


Regards, 
Thavasianand S. 



YY Yoab Youssoufou July 27, 2020 02:20 PM UTC

Thanks so much, sorry for the delay I thought I had replied you. It's perfect


BS Balaji Sekar Syncfusion Team July 28, 2020 05:16 AM UTC

Hi Yoab, 
 
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