Grid MVC Destroy with FK and EF code first approach help

2 posts, 0 answers
  1. Pierre
    Pierre avatar
    260 posts
    Member since:
    Apr 2007

    Posted 27 Sep 2018 Link to this post

    Hi there,

    I got 2 EF Code first tables

    public class ActionGES
            public int ActionGESID { get; set; }
            public string TitreAL { get; set; }
            public string Description { get; set; }
            public ICollection<IndicateurAction> Indicateurs { get; set; }
    public class IndicateurAction
            public int IndicateurActionID { get; set; }
            public int Indicateur { get; set; }
            public int Annee { get; set; }
            public bool ApprouveEA { get; set; }
            //FK Key       
            public int ActionGESId { get; set; }
            public ActionGES ActionGES { get; set; }

    work good with LINQ with .include

    My question is: it is normal that when I call Destroy on my grid, I ActionGES object are created in the controller action with FK Indicateurs collection count = 1 but with en [0] item = null...

    My Controller action

    //POST: Actions_Destroy
    public ActionResult Actions_Destroy([DataSourceRequest] DataSourceRequest request, ActionGES act)
        if (act != null && ModelState.IsValid)
        return Json(new[] { act }.ToDataSourceResult(request, ModelState));


    The "act" variable contain a Indicator with a null item. Look the picture.


  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 01 Oct 2018 Link to this post

    Hi Pierre,

    Could you please share the Grid configuration, so we could get better idea of the exact configuration? As a side note, please have in mind that the Grid is not designed to work with nested collections, but if the data is present in the Grid's DataSource, it should be passed correctly to the controller.

    Looking forward to your reply with the Grid's configuration.

    Konstantin Dikov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top