MudSelectExtended - Not binding values when using WebAssembly
miguelmachado17 opened this issue · comments
Hello,
I don't seem to be able to automatically select values whenever i'm using WebAssembly.
On the first render (using server mode) it's able to select the values passed to the variable "selectedApplicationUsers" automatically, but the same doens't happen when i reload the page and use WASM instead.
Below is the code that i currently using.
<MudSelectExtended T="ApplicationUser"
ItemCollection="applicationUsers"
@bind-SelectedValues="selectedApplicationUsers"
Label="Users"
ToStringFunc="@(v => v?.FirstName)"
Variant="Variant.Text"
ValuePresenter="ValuePresenter.Chip"
Virtualize="true"
ChipCloseable="true"
ChipVariant="MudBlazor.Variant.Filled"
ChipSize="MudBlazor.Size.Small"
MultiSelection="true"
MultiSelectionTextFunc="@(new Func<List<ApplicationUser>, string>(GetMultiSelectionText))" />
public List<TaskUser>? taskUsers { get; set; }
public List<ApplicationUser> applicationUsers { get; set; } = new List<ApplicationUser>();
public List<ApplicationUser> usersInTask { get; set; } = new List<ApplicationUser>();
public IEnumerable<ApplicationUser> selectedApplicationUsers { get; set; } = new List<ApplicationUser>();
protected override async Task OnInitializedAsync()
{
applicationUsers = await ApplicationUserSevice.GetAll();
taskUsers = await TaskUserService.GetAllByMainTaskId(mainTask.Id);
foreach (var taskData in taskUsers)
{
ApplicationUser? user = await ApplicationUserSevice.GetById(taskData.ApplicationUserId);
usersInTask.Add(user);
}
selectedApplicationUsers = usersInTask;
MudDialog.StateHasChanged();
await base.OnInitializedAsync();
}
private string GetMultiSelectionText(List<ApplicationUser> selectedValues)
{
return $"{string.Join(", ", selectedValues.Select(x => x.FirstName))}";
}
I checked, and the API calls are working and retrieving the exact same data as when using server mode.
Is this a bug or am i doing something wrong?