Open PlayerModu opened 11 months ago
Working try.* snippet which shows the issue. Posting on here for exposure incase anyone else has this issue and isn't on the Discord ☺️
<MudComboBox T="PracticeInformationDto" @bind-SelectedValues="_practicesToOverwrite"
Label="Practice"
Clearable="true"
ShowCheckbox="true"
Editable="true"
MultiSelection="true"
Margin="Margin.Dense">
@foreach (var item in _filteredPracticesToOverwrite)
{
<MudComboBoxItem Value="@item"
Text="@("P0" + @item.PracticeCode + " - " + @item.PracticeName)">
@item
</MudComboBoxItem>
}
</MudComboBox>
@code {
public class PracticeInformationDto
{
public string PracticeCode { get; set; }
public string PracticeName { get; set; }
}
private List<PracticeInformationDto> _filteredPracticesToOverwrite = new()
{
new PracticeInformationDto()
{
PracticeCode = "1234",
PracticeName = "ABC"
},
new PracticeInformationDto()
{
PracticeCode = "4321",
PracticeName = "CBA"
},
};
private IEnumerable<PracticeInformationDto> _practicesToOverwrite;
}
Updating:
Until this can be done automatically, this error can be resolved by passing a custom converter to the Converter
property on the MudComboxBox
Converter<PracticeInformationDto> _converter = new Converter<PracticeInformationDto>
{
SetFunc = value => value.PracticeName
};
When using the MudComboBox with T of an object type, and using the default search box, I am seeing a type conversion error underneath the component when I select one or more of the options in the list. However I do not see this type conversion error if I scroll through and select the same objects from the list manually.
Error: "Conversion to type PersonDto not implemented"
I've tried to include the relevant code below:
Please can you advise? This is a hard-blocker to me using this component. Given the docs only show an example of a simple string type, I can't see if it's a me issue or a component issue.
Notes - I'm using the latest version of this library and MudBlazor