Hi,
I have a Blazor Server Application, on one of my Blazor pages I am using a Radzen data grid. There is a currency dropdown on the data grid. I want to change the Unit Cost currency based on selection. The problem is If I change one of the row's currency, all of the row's currency is set to the selected one. How can I fix this?
Here is the page;
I have a Blazor Server Application, on one of my Blazor pages I am using a Radzen data grid. There is a currency dropdown on the data grid. I want to change the Unit Cost currency based on selection. The problem is If I change one of the row's currency, all of the row's currency is set to the selected one. How can I fix this?
Here is the page;
related portion:
<RadzenDataGridColumn TItem="OrderDetail" Property="Currency" Title="Currency">
<EditTemplate Context="orderDetail">
<RadzenDropDown AllowClear="true" TValue="string" Class="w-100" Data=@currency @bind-Value="orderDetail.Currency" Name="Currency" Change=@(args => OnChange(args))/>
<RadzenRequiredValidator Text="Currency is required" Component="Currency" Popup="true" Style="position: absolute"/>
</EditTemplate>
</RadzenDataGridColumn>
<RadzenDataGridColumn TItem="OrderDetail" Property="UnitCost" Title="Unit Cost">
<EditTemplate Context="orderDetail">
@*<RadzenNumeric TValue="double" Min="1" @bind-Value="orderDetail.UnitCost" Style="width: 100%; display: block" Name="UnitCost"/>
<RadzenRequiredValidator Text="Unit Cost is required" Component="UnitCost" Popup="true" Style="position: absolute"/>*@
@switch (SelectedCurrency)
{
case "Dolar":
@string.Format(new CultureInfo("en-US"), "{0:C}", orderDetail.BuyQuantity * orderDetail.CostRatio)
break;
case "Euro":
@string.Format(new CultureInfo("en-FR"), "{0:C}", orderDetail.BuyQuantity * orderDetail.CostRatio)
break;
default:
@string.Format(new CultureInfo("tr-TR"), "{0:C}", orderDetail.BuyQuantity * orderDetail.CostRatio)
break;
}
</EditTemplate>
<Template Context="detail">
@switch (SelectedCurrency)
{
case "Dolar":
@string.Format(new CultureInfo("en-US"), "{0:C}", detail.BuyQuantity * detail.CostRatio)
break;
case "Euro":
@string.Format(new CultureInfo("en-FR"), "{0:C}", detail.BuyQuantity * detail.CostRatio)
break;
default:
@string.Format(new CultureInfo("tr-TR"), "{0:C}", detail.BuyQuantity * detail.CostRatio)
break;
}
</Template>
@*<FooterTemplate>
<b>@string.Format(new CultureInfo("en-US"), "{0:C}", SelectedOrders?.FirstOrDefault()?.OrderDetails.Sum(o=>o.BuyQuantity * o.CostRatio))</b>
</FooterTemplate>*@
</RadzenDataGridColumn>
[Parameter]
public string SelectedCurrency { get; set; }
readonly List<string> currency = new() { "TL", "Dolar", "Euro"};
protected override async Task OnInitializedAsync()
{
_orders = await ViewAllOrdersUseCase.ExecuteAsync();
SelectedOrders = new List<Order?> { _orders.FirstOrDefault() };
_vendors = await ViewAllVendorsUseCase.ExecuteAsync();
}
private void OnChange(object args)
{
SelectedCurrency = args.ToString();
}