Hello,
in our grid we have a ForeignKey-column to show the Text of a dropodown instead of the Value (see discussion here: https://www.telerik.com/forums/telerik-mvc-grid---show-selectlistitem-text-instead-of-value):
columns.ForeignKey(c => c.STATUS, Helper.IDTB_PRUEFUNG.Dropdowns.Status, "Value", "Text");
This is the corresponding dropdown:
public class Dropdowns
{
public static List<SelectListItem> Status
{
get
{
return new List<SelectListItem>()
{
new SelectListItem()
{
Text = "New",
Value = "NEU",
Selected = true
},
new SelectListItem()
{
Text = "Locked",
Value = "GESPERRT"
}
};
}
}
}
The Read-Action on the server is fairly simple:
[AcceptVerbs(HttpVerbs.Post)]
public JsonResult Read([DataSourceRequest] DataSourceRequest request, int lot_id)
{
var pruefungen = db.IDTB_PRÜFUNG.Where(p => p.LOT_ID == lot_id);
return Json(pruefungen.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
Now when we sort this column, the sorting is applied on the Value. I assume this is because the sorting is done on the database level? (We use Entity Framework here.)
Is there a way to have the sorting applied on the Text instead of the Value?
(I am aware that this is asking for a bit of magic here, since the database only knows about the Value and knows nothing about the Text. So I would even be happy for some hints in the a general direction to solving this (maybe client-side sorting, or sth. else). :) )