Hi
I have a grid that has a foreign key to lookup and display the value from another table. I want to make the column into a hyperlink when not in edit mode, to go and view the related record. I can't seem to get the textual value to display, it's fine obviously with the numerical FK value.
My code is :
.Columns(columns =>
{
columns.ForeignKey(p => p.PrimaryKeyId, ds => ds.Read(r => r.Action("CustomerList", "Customer")), "CustomerId", "CustomerName")
.Title("Company")
.ClientTemplate("<a href='/Customer/Edit/#=data.PrimaryKeyId#' class='link-primary'>#=data.Customer.CustomerName#</a>")
.HeaderHtmlAttributes(new { @class = "small" });
columns.Bound(c => c.Primary).HeaderHtmlAttributes(new { @class = "small" });
columns.ForeignKey(p => p.SiteId, ds => ds.Read(r => r.Action("xCustomerSitesJSon", "Customer", new { custId = 0 })), "SiteId", "SiteName")
.Title("Site")
.HeaderHtmlAttributes(new { @class = "small" });
columns.Command(command =>
{
command.Edit();
});
})
Obviously it is the #=data.Customer.CustomerName# part that doesn't work - I understand that the Customer isn't really part of the data array, but not sure if / how this can be accessed?
Thanks