Custom Editor for Foreign key shows blank in grid when select the newly added value

3 posts, 0 answers
  1. Dev
    Dev avatar
    2 posts
    Member since:
    May 2020

    Posted 06 May 2020 Link to this post

    I have a Grid with foreign key column 'Products' with custom editor template. There is a separate button 'Add new Product; which opens up a modal to add new product . After adding new product when I try to create a new record in the Grid and select the newly added product, it shows up as blank in the Grid. When I refresh the page it shows up then. What I am missing?

    Foreign key in grid:

    columns.ForeignKey(c => c.ID, (System.Collections.IEnumerable)ViewData["products"], "ID",  "ProductName").Title("Product")..EditorTemplateName("RemoteForeignKeyProducts).

     
    'RemoteForeignKeyProducts' is the custom editor template for products:
    @model object 
    @(Html.Kendo().DropDownListFor(m => m)
      .DataSource(source =>
      {
          source.Read(read =>
          {
             read.Action("GetProducts", "Home").Type(HttpVerbs.Post);
          }).ServerFiltering(false);
      })
      .DataValueField("ID")
      .DataTextField("ProductName")

    )

    GetProducts() is a function in controller
      public ActionResult GetProducts()
            {
                using (     var db = new Entities())
                {
                    var objects = db.Products.Select(p => new { p.ID, p.ProductName}).ToList();

                    return Json(objects);
                }

            }

     

  2. Dev
    Dev avatar
    2 posts
    Member since:
    May 2020

    Posted 06 May 2020 Link to this post

    Can anyone help me out with this. Its really urgent..
  3. Angel Petrov
    Admin
    Angel Petrov avatar
    1155 posts

    Posted 08 May 2020 Link to this post

    Hello,

    Based on the information provided it would be difficult to determine what is causing the problem. Can you please send us the entire grid code alongside with the controller actions and models so we could examine the setup? If you can instead send us a small sample that would be great.

    Additionally please check whether the request is executed and exceptions are not thrown.

    Regards,
    Angel Petrov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top