Seven price
asked on
GridMVC
I want to add if qty >1 then qty / Price else just show price
how can I do this within the grid.
I cannot do it in the storedprocedure because the price is int not a string with my mvc project.
how can I do this within the grid.
I cannot do it in the storedprocedure because the price is int not a string with my mvc project.
@Html.Grid(Model).Named("Grid").Columns(columns =>
{
columns.Add(c => c.ItemDescription).Titled("Description").SetWidth(850);
columns.Add(c => c.ScanPrice).Titled("Price").Css("money").SetWidth(200).Direction.Equals("right");
columns.Add(c => c.BasePrice).Titled("qty").Css("money").SetWidth(200);
columns.Add(c => c.CreatedDate).Titled("Created Date").SetWidth(200).Format("{0:dd-MMM-yyyy}");
}).WithPaging(10).Sortable(true)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
(x.Qty / x.Price).ToString()
this part is dividing instead of using the slash as a empty string.
I thought you wanted to divide. If you just wanted to show a string literal then:
Giannis
columns.Add().RenderValueAs(x => x.Qty == 1 ? "Price" : "Qty / Price").Titled("YourColumnName");
Giannis
ASKER
I just convert / to "/" and it worked out. Thanks
You can use a viewmodel or add a property on your model to reflect that behaviour and ignore it for the database if you're using codefirst.
Regards,
Mishu