Kendo UI Foreign Key

2019-07-23 11:58发布

I am new to Kendo UI and I got this problem. I don't understand, what are the basic steps in showing child object information in a column with a foreign key property. I mean, what do I have to do to create a foreign key column. It might be a silly question, but I saw a demo of foreign key on demos pages http://demos.telerik.com/kendo-ui/web/grid/foreignkeycolumn.html, still, I didn't quite get how does it work.

Thanks, Vidmantas

1条回答
Fickle 薄情
2楼-- · 2019-07-23 12:15

Below is the MVC example for foreign key column demo:

Its as simple as it sounds,

For example, lets say you have CoachId field in a table and its the foreign key of the table Coach that has CoachId and Name columns. Now you wish to present the Coach Name instead of the CoachId in the Grid.

columns.ForeignKey(student => student.CoachId,
            (System.Collections.IEnumerable)ViewBag.Coaches, "CoachId", "Name")
           .Title("Coach");

Then from the controller or from Code you have to send all the coach records in Viewbag or Viewdata.

Cheers!!

查看更多
登录 后发表回答