The Value field in the ComboBox component must be of type string when the AllowCustom feature is enabled. If you need to use a different type for the Value field, you can use the CustomValueSpecifier event to send the Item instead.
For more information, please refer to the documentation and sample code provided in the release notes at this link: https://blazor.syncfusion.com/documentation/release-notes/18.3.35?type=all#combobox
|
<div id="ControlRegion"> <div class='control-wrapper'> <p>@ComboVal</p> <SfComboBox TValue="decimal" TItem="EmployeeData" CssClass="template" Placeholder="Select a customer" DataSource="@Data" AllowCustom="true" AllowFiltering="true" @bind-Value="ComboVal"> <ComboBoxFieldSettings Value="UnitCost" Text="UnitCost"></ComboBoxFieldSettings> <ComboBoxEvents TValue="decimal" TItem="EmployeeData" CustomValueSpecifier="@customValue"></ComboBoxEvents> </SfComboBox> </div> </div>
@code { public decimal ComboVal;
private void customValue(CustomValueSpecifierEventArgs<EmployeeData> args) { args.Item = new EmployeeData() { UnitCost = decimal.Parse(args.Text), TypeOfUse = args.Text }; } public class EmployeeData { public string TypeOfUse { get; set; } public decimal UnitCost { get; set; } } List<EmployeeData> Data = new List<EmployeeData>();
} |
[ Reference ]
|
|
Good Day UdhayaKumar Duraisamy ,
Thanks for the reply .. it working..
Nelson
Thank you for letting us know that it's working! We are glad to help.
Hi UdhayaKumar,
Can you please help.
I want to get the following functionality in the ComboBox like image that I have attached.
But, the sample in the link does not provide the functionality, even though AllowCustom is true.
Can you please tell me what I am doing wrong?
Hi, I found answer in another post.
Documentation was not clear. I think that it needs to be improved.
Hi steve,
Thanks for pointing that out! Since you’ve found the answer, we’ll make sure to update the documentation in one of our upcoming releases to reflect it more clearly.
Regards,
Priyanka K