I am trying to clear all selected values from a TelerikRadioGroup. I would like to do this by clicking on the selected value. The problem is the OnChange and the ValueChanged does not fire unless you are clicking on a different value.
<TelerikRadioGroup Data="@genderOptions"
Value="@selectedGender"
OnChange="@OnChangeHandler"
ValueChanged="@((int newValue) => OnGenderChanged(newValue))"
ValueField="@nameof(GenderModel.GenderId)"
TextField="@nameof(GenderModel.GenderText)"
Layout="RadioGroupLayout.Horizontal">
</TelerikRadioGroup>
@code {
private int selectedGender;
private void OnGenderChanged(int newValue)
{
if (selectedGender == newValue)
{
var aa = 123;
}
else
{
selectedGender = newValue;
Console.WriteLine($"Gender changed to: {newValue}");
}
}
async Task OnChangeHandler(object newValue)
{
// the handler receives an object that you may need to cast to the type of the component
// if you do not provide a Value, you must provide the Type parameter to the component
Console.WriteLine($"ValueChanged fired with value: {newValue as string}");
}
}