Extract date from other object based on Foreign Key

Iny my ASP.NET Web Api I use two classes.
public class Order
{
public int Id{get; set}
public int CategoryId { get; set; }
public Category Category { get; set; }
}
The class above I use to display thier data in grid. In column category it displays me the number reffering to Id from table Category.
Class category
public class Category
{
public int Id{get; set}
public string Name { get; set; }
}
Is it possible to get the name of category and display it instead of number showing the FK of this category in grid?


1 Reply

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team November 3, 2017 10:06 AM UTC

Hi Mac,  
 
Thanks for contacting Syncfusion Support.  
 
Grid provides an option to render the Complex column using the dot(.) separator. Refer to the following code example and demo.  
 
<div id="FlatGrid"></div> 
<script type="text/javascript"> 
    $("#FlatGrid").ejGrid({ 
        dataSource: dm, 
        allowPaging: true, 
        columns: [ 
            { field: "Id", headerText: "Customer ID", isPrimaryKey: true }, 
            { field: "CategoryId", headerText: "Company Name" }, 
            { field: "Category.Id", headerText: "Contact Name" }, 
            { field: "Category.Name", headerText: "Customer ID" } 
        ] 
    }); 
 
</script> 
 
 
Regards,  
Seeni Sakthi Kumar S. 


Loader.
Up arrow icon