New to Telerik UI for ASP.NET CoreStart a free 30-day trial

Enabling ForeignKey Column Sorting by Text

Updated on Sep 16, 2026

Environment

ProductProgress Telerik UI for ASP.NET Core Grid
Progress Telerik UI for ASP.NET Core versionCreated with the 2023.1.314 version

Description

How can I enable ForeignKey column sorting by text in the Telerik UI for ASP.NET Core Grid?

Solution

The following example demonstrates how to enable the sort-by-text functionality in a ForeignKey column by adding the text field in the Grid.

To achieve the desired scenario:

  1. Add the complex model field that is corresponding for the ForeignKey column.
  2. Subscribe to the document.ready() event after the Grid declaration, get a reference of the header for the ForeignKey column, and change the data-kendo-field attribute to point to the text field.

If the Grid uses deferred initialization, place the handler after the deferred scripts are rendered. This example uses ServerOperation(false), so the Grid sorts the returned data on the client by the text field.

C#
     public class ProductViewModel
     {
         public int ProductID
         {
             get;
             set;
         }

         public string ProductName
         {
             get;
             set;
         }

         public decimal UnitPrice
         {
             get;
             set;
         }

         public CategoryViewModel Category
         {
            get;
            set;
         } 

         public int? CategoryID { get; set; }
     }

Place the script in the same .cshtml view after the Grid markup, or in an @section Scripts that the layout renders after the view content. The Grid must be initialized before the handler runs.

For the complete implementation of the suggested approach, refer to the Telerik REPL example on enabling foreign key column sorting by text in the Grid.

More ASP.NET Core Grid Resources

See Also