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 ( primary key from parent grid is null)

Hi, can I know why i get null value of ID from parent grid when I click edit button?  *picture below for reference

 function actionBeginVehicle(e) {  // childGrid actionBegin event
        var grid = document.getElementsByClassName("e-grid")[0].ej2_instances[0]; //parent grid
        var childGrid = document.getElementById("childGrid").ej2_instances[0]; //child grid

        alert(e.requestType);

        if (e.requestType == "beginEdit" ) {
        
           
            childGrid.query.addParams("driver_id", grid.getSelectedRecords()[0].driver_id);

        }
        else if (e.requestType == "save" && e.action == "add") {

            childGrid.query.addParams("driver_id", grid.getSelectedRecords()[0].driver_id);
            childGrid.refresh();
        }
    }



Controller
 public IActionResult UpdateVehicle([FromBody] CustomCRUDModel<VehicleDetails> value)
        {

            VehicleDetails result = new VehicleDetails();
            result.driver_id = value.Params.driver_id;
            result.id = value.Value.id;
            result.plateno = value.Value.plateno;
            result.carmodel = value.Value.carmodel;
            result.carbrand = value.Value.carbrand;
            result.carcolor = value.Value.carcolor;
            result.year = value.Value.year;
            //result.servicetype = value.Value.servicetype;

            result = new DriverDAL().EditVehicle(result);
            string msg = "Update";
            return Json(new { data = result, message = msg });

            //return Json(result);
        }

        public class CustomCRUDModel<T> where T : class
        {
            public string Action { get; set; }
            public string Table { get; set; }
            public string KeyColumn { get; set; }
            public object Key { get; set; }
            public T Value { get; set; }
            public List<T> Added { get; set; }
            public List<T> Changed { get; set; }
            public List<T> Deleted { get; set; }
            public VehicleDetails Params { get; set; }
            public Attachment ParamsAtt { get; set; }

        }




1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team January 10, 2020 10:27 AM UTC

Hi Muhamad, 
 
Thanks for contacting Syncfusion support. 
 
Based on your query you need to get the value of an ID from parent grid when you click on Edit button. But in the attached screenshot, we did not find any hierarchical grid. In your attached screenshot we suspect that you have render the grid with car details inside the dialog when you click on the car icon of an grid behind the dialog.  
 
To provide an solution, please share the details 
 
1. Complete Grid code example.  
 
2. Share the video demonstration of an issue.  
 
3. Syncfusion Package version details.   
 
Regards, 
Prasanna Kumar N.S.V 


Loader.
Live Chat Icon For mobile
Up arrow icon