Telerik Extensions for ASP.NET MVC

Version Q2 2012, released 06/07/2012

ForeignKey Column

Order ID
Filter
Employee ID
Filter
Order Date
Filter
Freight
Filter
 
No records to display.
Displaying items 0 - 0 of 0

About this example ASPXRazor

This example shows how to use Telerik Grid for ASP.NET MVC foreign key column to show related data.

The related data should be provided as either SelectList or IEnumerable:

  Html.Telerik().Grid>ClientEditableOrder>()
           .Name("Grid")                      
           .Columns(columns =>
           {
               columns.Bound(o => o.OrderID).Width(100);
               columns.ForeignKey(o => o.EmployeeID, (IEnumerable)ViewData["employees"],
                   "ID", "Name").Width(230);
               columns.Bound(o => o.OrderDate).Width(150);
               columns.Bound(o => o.Freight).Width(220);               
           })                      

When switched to edit mode, by default Telerik DropDownList for ASP.NET MVC will be shown as column editor. This can be changed by modifing the GridForeignKey editor template.

Interested in HTML5 and mobile-powered ASP.NET MVC apps?

Experience the next generation UI and framework for ASP.NET MVC development by downloading trial evaluation copy of Kendo UI Complete for ASP.NET MVC. Jumpstart your development with the available learning resources.

The differences between Telerik MVC Extensions and Kendo UI Complete for ASP.NET MVC, and their licensing models are explained here and here.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Other Demos: