Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Multiselect on MudBlazor not updating text field

I am using MudBlazor for a Blazor project. I am trying to create a multiselect component using Enums. I have it working so that the component shows and the selections being chosen correctly. The issues are coming up with the actual display of the component. First of all, even if nothing has been chosen, the first entry’s text is being displayed which overlaps the label given to the component. Secondly, once I choose different components, the text does not update even though I have the MultiSelectionTextFunc set and when debugging, I see that the called function is producing the correct text. Here is a link to the demo: https://try.mudblazor.com/snippet/GOwIYdloqAKBdPcl

I just want to figure out how to resolve the overlapping text and why my text is not updating.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to use T="Color?" instead of T="Color":

@using Try.UserComponents

<MudSelect T="Color?" Label="Choose a color" MultiSelection="true" SelectAll="true" SelectAllText="Select All" @bind-SelectedValues="SelectedColors" AdornmentIcon="@Icons.Material.Filled.Search" AnchorOrigin="Origin.BottomCenter">
    <MudSelectItem T="Color?" Value="Color.Red">Red</MudSelectItem>
    <MudSelectItem T="Color?" Value="Color.Blue">Blue</MudSelectItem>
    <MudSelectItem T="Color?" Value="Color.LightBlue">Light Blue</MudSelectItem>
</MudSelect>

@code {
    private IEnumerable<Color?> SelectedColors { get; set; } = new HashSet<Color?>();
}

https://try.mudblazor.com/snippet/mYGSkxlyKBgQuJlK

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading