Edit dynamically loaded child grid

Regards, I want to add dialog editing on my child grid, but when I load the child grid dynamically the dialog editing doesn't work, how can I send the changed records to my server method when dynamically loading the child grid?

var SecondChild = new Syncfusion.EJ2.Grids.Grid()
    {
        DataSource = new Syncfusion.EJ2.DataManager()
        {
            Json = Model.salesOrderLines,
            Adaptor = "RemoteSaveAdaptor",
            UpdateUrl = "/SalesOrdersProcessing/Update",
        },
        QueryString = "orderLine",
        Width = "80%",
        RowHeight = 20,
        AllowResizing = true,
        Load = "OnLoadChild2",
        AllowReordering = true,
        EditSettings = new Syncfusion.EJ2.Grids.GridEditSettings()
        {
            AllowEditing = true,
            Mode = Syncfusion.EJ2.Grids.EditMode.Dialog
        },
        Columns = new List<Syncfusion.EJ2.Grids.GridColumn> {
                new Syncfusion.EJ2.Grids.GridColumn(){ Field="orderLine", Visible=false,Width="80",AllowEditing=false, HeaderText="OrderLine",TextAlign=Syncfusion.EJ2.Grids.TextAlign.Left },
                new Syncfusion.EJ2.Grids.GridColumn(){ Field="objectID",Width="40",AllowEditing=false, HeaderText="Магацин",TextAlign=Syncfusion.EJ2.Grids.TextAlign.Left },
                new Syncfusion.EJ2.Grids.GridColumn(){ Field="objectName",Width="80",AllowEditing=false, HeaderText="Назив на магацин", Format="C2", TextAlign=Syncfusion.EJ2.Grids.TextAlign.Left },
/*
                new Syncfusion.EJ2.Grids.GridColumn(){ Field="backorderQTY",Width="80",AllowEditing=false,HeaderText="BackOrder",TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right },
                new Syncfusion.EJ2.Grids.GridColumn(){ Field="backorderExpectedReceivingDate",Width="80",AllowEditing=false,HeaderText="Очекуван Датум на Прием",CustomFormat=new { type ="date", format="dd.MM.yyyy" },TextAlign =Syncfusion.EJ2.Grids.TextAlign.Right },
*/
                new Syncfusion.EJ2.Grids.GridColumn(){ Field="backOrder",Width="60px", AllowEditing=false,HeaderText="BackOrder",TextAlign =Syncfusion.EJ2.Grids.TextAlign.Left },
                new Syncfusion.EJ2.Grids.GridColumn(){ Field="aQuantity",Width="80",AllowEditing=false, HeaderText="Достапна количина",Format="N3",TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right },
                new Syncfusion.EJ2.Grids.GridColumn(){ Field="qtyForOrder",Width="80",AllowEditing=true,EditType="numericedit",HeaderText="За испорака",TextAlign=Syncfusion.EJ2.Grids.TextAlign.Right },
                },
        //BeforeBatchSave = "beforeBatch",
        //ActionComplete="actionComplete"
    };
function OnLoadChild2(args) {
        obj.push(this);
        var model = {
            DocNo: this.parentDetails.parentRowData.docNo,
            wYear: this.parentDetails.parentRowData.wyear,
            DocType: this.parentDetails.parentRowData.docType,
            sessionID: this.parentDetails.parentRowData.sessionID,
            DocLine: this.parentDetails.parentRowData.docLine
        }
        var ajax = new ejs.base.Ajax({
            type: "POST",
            url: '/SalesOrdersProcessing/getSaleOrderLines',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(model)
        });
        ajax.send().then(function (result) {
            var data = JSON.parse(result);
            this.dataSource = data;
        }.bind(this));
    }

[Controller.cs]
[HttpPost]
        public IActionResult Update([FromBody]CRUDModel<SalesModel> m)
        {
         }

1 Reply 1 reply marked as answer

TS Thiyagu Subramani Syncfusion Team May 7, 2021 11:57 AM UTC

Hi Tarik, 

Thanks for contacting Syncfusion support. 

Based on your shared information we have prepared sample as per your requirement but unfortunately your reported issue doesn’t reproduced at our end. Child Grid’s dialog editing works perfectly. Please refer to the below code and sample link. 

@{ 
    var data = new Syncfusion.EJ2.DataManager() 
    { 
        Json = ViewBag.DataSource2.ToArray(), 
        Adaptor = "RemoteSaveAdaptor" 
    }; 
    var ChildGrid = new Syncfusion.EJ2.Grids.Grid() 
    { 
        Width = "80%", 
        RowHeight = 20, 
        AllowResizing = true, 
        Load = "OnLoadChild2", 
        AllowReordering = true, 
        EditSettings = new Syncfusion.EJ2.Grids.GridEditSettings() 
        { 
            AllowEditing = true, 
            Mode = Syncfusion.EJ2.Grids.EditMode.Dialog 
        }, 
. . . . . .  . 
        QueryString = "EmployeeID", 
        Toolbar = new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" }, 
        Columns = new List<Syncfusion.EJ2.Grids.GridColumn> { 
    new Syncfusion.EJ2.Grids.GridColumn(){ Field="UnitID", IsPrimaryKey=true, HeaderText="Unit ID" }, 
    new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipName", HeaderText="Ship Name" }, 
    new Syncfusion.EJ2.Grids.GridColumn(){ Field="ShipAddress", HeaderText="Ship Address" } 
} 
    }; 
} 
 
<script> 
    var obj; 
    function OnLoadChild2(args) { 
        //obj.push(this); 
        var model = { 
            DocNo: this.parentDetails.parentRowData.OrderID, 
            wYear: this.parentDetails.parentRowData.EmployeeID, 
            DocType: this.parentDetails.parentRowData.CustomerID 
        } 
        var ajax = new ej.base.Ajax({ 
            type: "POST", 
            url: "/Home/getSaleOrderLines", 
            contentType: "application/json; charset=utf-8", 
        }); 
        var data = JSON.stringify({ FilteredValue: model }); 
        ajax.send(data).then(); 
        ajax.onSuccess = result => { 
            var data = JSON.parse(result); 
           // this.dataSource = data; 
        }; 
    } 
</script> 
 
public ActionResult getSaleOrderLines([FromBody]SelectedModel row) 
        { 
            //perfoerm your action here as per your needs. 
            return Json(row); 
        } 
        public class SelectedModel 
        { 
            public object FilteredValue { get; set; } 
        } 
 


Screenshot:  

 

 


If still facing the issue, please share issue reproducing sample or reproduce the issue in above sample, video demonstration of your issue and Syncfusion package version to us then only we can provide appropriate solution as soon as possible. 

Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S  


Marked as answer
Loader.
Up arrow icon