New to Blazor and Radzen, so bear with me (I'm a backend C# gal by trade).
I've got me a nice DataGrid and I want to add the ability to update columns that take a value based upon a dropdown.
For the Display I'm calling a function that converts that saved value (a byte?
) and converts it to text.
So, what I'm after (inside my EditTemplate
) is the ability to take something like a SortedList
and use that in my Dropdown control.
This is what I've managed to put together (not working):
<RadzenDataGridColumn TItem="Data" Property="AccountStatus" Filterable="false" Title="Status" Frozen="false" Width="30px" TextAlign="TextAlign.Center">
<Template Context="data">
<RadzenText>@Data.GetAccountStatusText(data.AccountStatus)</RadzenText>
</Template>
<EditTemplate Context="data">
<RadzenDropDown TValue="string" @bind-Value="distributor.AccountStatus" Style="width:50px; display: block" Name="Account Status" Data=@Data.AccountStatuses/>
</EditTemplate>
</RadzenDataGridColumn>
And
public static string GetAccountStatusText(byte? status)
{
if (!status.HasValue)
return $"? ${status}";
var v = status.GetValueOrDefault();
var d = AccountStatuses();
return d.TryGetValue(v, value: out var text) ? text : $"{v} - Not defined";
}
public static SortedList<byte, string> AccountStatuses()
{
var ret = new SortedList<byte, string>
{
{ 0, "Inactive" },
{ 1, "Active" },
{ 255, "Undefined" }
};
return ret;
}
I'm confused about how to split out the Key and the value of the SortedList
within the RadzenDropDown
so it displays the Value
but stores the Key
. I see there's some references to what I might need within the control, but I'm missing the ability to connect the dots (as it where),