Completed
Last Updated: 05 Feb 2024 12:12 by ADMIN
Court
Created on: 27 Apr 2020 18:49
Category: Grid
Type: Feature Request
0
Missing code in demo website example

https://demos.telerik.com/aspnet-mvc/grid/foreignkeycolumn

In addition to the Foreign Key editor template, populate a list which holds all the categories and pass it via the ViewData - you can see how this is done in the ForeignKeyColumnController.cs PopulateCategories() method.

On the above page, the above statement is made.  Other than the function call to PopulateCategories() I don't ever see the actual code run in the function shown anywhere.  Can someone please add that code and/or point me to my misunderstanding?

Thank you.

Court Harris
Equity Residential

1 comment
ADMIN
Silviya Stoyanova
Posted on: 30 Apr 2020 08:56

Hello Court,

Thank you for pointing out the missing method in the provided Demo! The code will be added.

Here is the actual method implementation:

private void PopulateCategories()
        {
            using (var dataContext = new SampleEntitiesDataContext())
            {
                var categories = dataContext.Categories
                            .Select(c => new CategoryViewModel
                            {
                                CategoryID = c.CategoryID,
                                CategoryName = c.CategoryName
                            })
                            .OrderBy(e => e.CategoryName);

                ViewData["categories"] = categories.ToList();
                ViewData["defaultCategory"] = categories.First();
            }
        }

 

Kind Regards, Silviya Stoyanova 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.