CodeBeamOrg / CodeBeam.MudBlazor.Extensions

Useful third party extension components for MudBlazor, from the contributors.
https://mudextensions.codebeam.org/
MIT License
348 stars 60 forks source link

How to use Select to choose the Descriptions of enum items with the Flags attribute in multi-selection mode? #376

Open yangf85 opened 1 month ago

yangf85 commented 1 month ago

hi ,everyone.

Cannot bind multiple selections to a model property.

image

image

image

When toggling the selection, the bound value is always 0. image

mckaragoz commented 1 month ago

If you use MultiSelection then you need to use @bind-SelectedValues instead of @bind-Value

yangf85 commented 1 month ago

If you use MultiSelection then you need to use @bind-SelectedValues instead of @bind-Value thanks. but this property is an IEnumerable type property. Do you mean it requires manual intervention to perform a conversion?

mckaragoz commented 1 month ago

If you use MultiSelection then you need to use @bind-SelectedValues instead of @bind-Value thanks. but this property is an IEnumerable type property. Do you mean it requires manual intervention to perform a conversion?

You can bind whatever you want that inherits IEnumerable. Example:

<MudSelectExtended @bind-SelectedValues="_values" />

@code {
  List<SheetMatelStep> _values;
}
yangf85 commented 1 month ago

Oh, I understand what you mean, but the property defined in the entity model is just a single Flags enum, not a collection property, so I still need to perform a manual conversion operation.

yangf85 commented 1 week ago

If you use MultiSelection then you need to use @bind-SelectedValues instead of @bind-Value thanks. but this property is an IEnumerable type property. Do you mean it requires manual intervention to perform a conversion?

You can bind whatever you want that inherits IEnumerable. Example:

<MudSelectExtended @bind-SelectedValues="_values" />

@code {
  List<SheetMatelStep> _values;
}

Hi ,Cannot bind 'selectedvales' to a List collection property, as in the following way, must be a IEnumerable Property

image