Hi Currently I am use a Column that shows "Cost" for each row.
Each row may have a different currency base, so I need to convert this Cost into a view-currency for an exchange rate.
So Displayed Cost = Cost * Exchange Rate
Currently, I used Template to do that:
<GridColumn Field="Cost">
<Template>
@{
if (context is Summary s)
{
if (s.Currency != viewCurrency)
{
var exchRate = MarketDataService.GetExchangeRate(s.Currency, viewCurrency);
<span>@((s.Cost* exchRate).ToString("N2"))</span>
}
else
{
<span>@(s.Cost.ToString("N2"))</span>
}
}
}
</Template>
</GridColumn>
However, my problem is that the sort still used the original s.Cost for sorting.
Roughly, I need the sort also to be calculated based on the ccy * exch.
What should be the right approach of doing this?
(I see alternative of either calculating (ccy * exch) as part of the datasource so that i can simply put it on a simple-column - but since my view currency can change (which is a setting), i want to avoid doing this as this means will need to recalculate the values for the entire datasource again.)
Thank you for your time in advance.