This is a migrated thread and some comments may be shown as answers.

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

2 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dev
Top achievements
Rank 1
Dev asked on 06 May 2020, 05:18 PM

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 Answers, 1 is accepted

Sort by
0
Dev
Top achievements
Rank 1
answered on 06 May 2020, 08:55 PM
Can anyone help me out with this. Its really urgent..
0
Angel Petrov
Telerik team
answered on 08 May 2020, 04:24 PM

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.
Tags
Grid
Asked by
Dev
Top achievements
Rank 1
Answers by
Dev
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or