Consider enum:
public enum ResponsavelCrianca : byte
{
[Display(Name = "Adulto responsável")]
AdultoResponsavel = 1,
[Display(Name = "Outra(s) criança(s)")]
OutraCrianca = 2,
[Display(Name = "Adolescente")]
Adolescente = 133,
[Display(Name = "Sozinha")]
Sozinha = 3,
[Display(Name = "Creche")]
Creche = 134,
[Display(Name = "Outro")]
Outro = 4
}
Consider componet:
<div class="form-group col-md-6">
<label>Criança de 0 a 9 anos, com quem fica?</label>
<RadzenListBox @bind-Value="responsavelCriancaResult"
TValue="IEnumerable<ResponsavelCrianca>"
Multiple="true"
Data="@(Enum.GetValues(typeof(ResponsavelCrianca)).Cast<ResponsavelCrianca>().Select(t => new { Text = $"{Tools.GetDisplayName(t)}", Value = t }))"
TextProperty="Text" ValueProperty="Value" Style="width:100%;" />
<ValidationMessage For="() => esusFichaCadastroIndividual.responsavelPorCrianca" />
</div>
Consider code:
private IEnumerable<ResponsavelCrianca> responsavelCriancaResult = new ResponsavelCrianca[] {};
UI does not update the checkbox, although the IEnumerable is filled in correctly (verified with event in Change (args)):
Now, I've added the change event to the component.
<RadzenListBox @bind-Value="responsavelCriancaResult"
TValue="IEnumerable<ResponsavelCrianca>"
Multiple="true"
Data="@(Enum.GetValues(typeof(ResponsavelCrianca)).Cast<ResponsavelCrianca>().Select(t => new { Text = $"{Tools.GetDisplayName(t)}", Value = t }))"
TextProperty="Text" ValueProperty="Value" Style="width:100%;"
Change="@(args => OnChangeResponsavelCrianca(args))"/>
<ValidationMessage For="() => esusFichaCadastroIndividual.responsavelPorCrianca" />
When I click on all:
But, when I click individually, waiting for the multiple choice, it displays only what was clicked on that step.
When I remove the bind-value and the Change event the UI works correctly.
OBS: The edit form is being opened as a modal.
<RadzenListBox TValue="IEnumerable<ResponsavelCrianca>"
Multiple="true"
Data="@(Enum.GetValues(typeof(ResponsavelCrianca)).Cast<ResponsavelCrianca>().Select(t => new { Text = $"{Tools.GetDisplayName(t)}", Value = t }))"
TextProperty="Text" ValueProperty="Value" Style="width:100%;"
/>
The problem also affects the RadzenDropDown component