I would like to be able to bind the RadioGroup to a nested property like so:
<TelerikRadioGroup Data="@RadioData"
@bind-Value="@ChosenOption"
ValueField="Child.Id"
TextField="Child.Text">
</TelerikRadioGroup>
@code {
public int ChosenOption { get; set; }
public class Parent<TItem>
{
public TItem Content { get; set; }
public Parent(TItem item)
{
Content = item;
}
}
public class Child
{
public int Id { get; set; }
public string Text { get; set; }
public Child(int id, string text)
{
Id = id;
Text = text;
}
}
public List<Parent<Child>> RadioData { get; set; } = new List<Parent<Child>>();
protected override void OnInitialized()
{
RadioData.Add(new Parent<Child>(new Child(0, "Item 1")));
RadioData.Add(new Parent<Child>(new Child(1, "Some text")));
RadioData.Add(new Parent<Child>(new Child(2, "Other text")));
RadioData.Add(new Parent<Child>(new Child(3, "Third text")));
base.OnInitialized();
}
}