Kendo UI Foreign Key

房东的猫 提交于 2019-12-11 08:22:39

问题


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:


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!!



来源:https://stackoverflow.com/questions/21934191/kendo-ui-foreign-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!