问题描述
我是Kendo UI的新手,但遇到了这个问题.我不明白,在具有外键属性的列中显示子对象信息的基本步骤是什么.我的意思是,创建外键列需要做什么.这可能是一个愚蠢的问题,但是我在演示页面上看到了一个外键演示 http://demos.telerik.com/kendo-ui/web/grid/foreignkeycolumn.html ,但是,我还不太清楚它是如何工作的.
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.
谢谢,维德曼塔斯(Vidmantas)
Thanks,Vidmantas
推荐答案
以下是外键列演示的MVC示例:
Below is the MVC example for foreign key column demo:
听起来很简单
例如,假设您在表中有CoachId字段及其表的外键具有CoachId和Name列的教练.现在,您希望在网格中显示教练名称"而不是"CoachId".
For example, lets say you have CoachId field in a table and its the foreign key of the tableCoach 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");
然后,您必须从控制器或代码中发送Viewbag或Viewdata中的所有教练记录.
Then from the controller or from Code you have to send all the coach records in Viewbag or Viewdata.
干杯!
这篇关于Kendo UI外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!