Sorting using another property from object

Feb 20, 2014 at 4:02 PM
Hi,

Basically i have this object
public class Product{
      public decimal Price {get;set;}
      public decimal CalculatedPrice {get;set;}
}
I want to show only the column Price in the Grid, but when it do the sort, i would like it to sort base on the CalculatedPrice property.

Is there a way of doing that ?

Thanks
Coordinator
Feb 22, 2014 at 10:01 AM
Hi. you can apply column to CalculatedPrice property but render Price property:
@Html.Grid(Model).Columns(columns=>{
       columns.Add(p=>p.CalculatedPrice).RenderValueAs(p=>p.Price.ToString())
}).Sortable()