I need to check if the form has changes.
For this, I use RadzenTemplateForm<>.EditContext property, which works fine for inputs like RadzenTextBox, but doesn't work for RadzenDropDown.
EditContext becomes "modified" only when RadzenDropDown changes at least two times, which seems to be a bug within RadzenDropDown.
Please, check the difference in the behavior in the small demo below:
<RadzenTemplateForm @ref="_form" Data="@_person">
<RadzenLabel Text="Name" /><RadzenTextBox @bind-Value="@_person.Name" Style="width: 100%;" />
<RadzenLabel Text="Country" /><RadzenDropDown @bind-Value="@_person.Country" Data="@_countries" Style="width: 100%;" />
<RadzenButton Text="Save" Disabled="@(!HasChanges())" />
</RadzenTemplateForm>
@code {
class Person
{
public string Name { get; set; }
public string Country { get; set; }
}
private RadzenTemplateForm<Person> _form;
private readonly Person _person = new();
private readonly IEnumerable<string> _countries = new List<string> { "USA", "Germany" };
private bool HasChanges()
{
return _form.EditContext.IsModified();
}
}
Please advise.