CodeBeam.MudBlazor.Extensions icon indicating copy to clipboard operation
CodeBeam.MudBlazor.Extensions copied to clipboard

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

Open yangf85 opened this issue 1 year ago • 5 comments
trafficstars

hi ,everyone.

Cannot bind multiple selections to a model property.

image

image

image

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

yangf85 avatar Apr 14 '24 13:04 yangf85

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

mckaragoz avatar Apr 14 '24 18:04 mckaragoz

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?

yangf85 avatar Apr 15 '24 00:04 yangf85

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;
}

mckaragoz avatar Apr 15 '24 08:04 mckaragoz

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 avatar Apr 15 '24 11:04 yangf85

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

yangf85 avatar May 05 '24 09:05 yangf85