We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

AllowCustom Not Working

Good Day Syncfusion Group,

 Can you please help me what is the solution for AllowCustom="true" is not working?, my source code is:

Thanks in Advance..

Nelson 
 



3 Replies

UD UdhayaKumar Duraisamy Syncfusion Team January 5, 2023 10:51 AM UTC

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>();

 

    }


Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/AllowCustom_TValue_is_decimal122530040


[ Reference ]

 



NT Nelson Tan January 6, 2023 03:52 PM UTC

Good Day UdhayaKumar Duraisamy ,


Thanks for  the reply .. it working..


Nelson



UD UdhayaKumar Duraisamy Syncfusion Team January 9, 2023 05:10 AM UTC

Thank you for letting us know that it's working! We are glad to help.


Loader.
Live Chat Icon For mobile
Up arrow icon