kim
1
Hello @Team
Have you ever tested this component with an enum as TValue? The following code will not render any items for some reason.
<RadzenRadioButtonList @bind-Value=@(Base.Item.PrintingType) TValue="PrintingType?">
<Items>
<RadzenRadioButtonListItem Text=@(Text.FromPrintingType(PrintingType.QRCode)) Value="PrintingType.QRCode" />
<RadzenRadioButtonListItem Text=@(Text.FromPrintingType(PrintingType.Barcode)) Value="PrintingType.Barcode" />
</Items>
</RadzenRadioButtonList>
enchev
2
Yes, it's tested.
Here is a non nullable enum:
<RadzenRadioButtonList @bind-Value=@enumValue TValue="Orientation">
<Items>
<RadzenRadioButtonListItem Text="Vertical" Value="Orientation.Vertical" TValue="Orientation" />
<RadzenRadioButtonListItem Text="Horizontal" Value="Orientation.Horizontal" TValue="Orientation" />
</Items>
</RadzenRadioButtonList>
@code {
Orientation enumValue = Orientation.Vertical;
}
and nullable enum:
<RadzenRadioButtonList @bind-Value=@enumValue TValue="Orientation?" Change=@((args) => OnChange(args, "RadioButtonList bound to enum"))>
<Items>
<RadzenRadioButtonListItem Text="Vertical" Value="Orientation.Vertical" TValue="Orientation?" />
<RadzenRadioButtonListItem Text="Horizontal" Value="Orientation.Horizontal" TValue="Orientation?" />
</Items>
</RadzenRadioButtonList>
@code {
Orientation? enumValue;
}
There is even a demo showing binding to nullable values:
https://blazor.radzen.com/radiobuttonlist
1 Like
kim
3
Thanks a lot for these!
I was missing the explicit TValue in the Items.