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

Set null when exists selected value in dropdownlist

When in dropdown list exist selected value and I entered value in textbox and press enter or click mouse outside, value in dropdown set to null. How this cancel?


Attachment: SolutionErrorDDList_5f148924.7z


4 Replies 1 reply marked as answer

SP Sureshkumar P Syncfusion Team February 16, 2023 06:50 AM UTC

Hi kavit,

After validating the provided information with the sample, the dropdownlist component index property value is the reason to change the component value after EditContext NotifyFieldChanged sets as a null value. So we suggest you remove the index property on dropdownlist component rendering code example to achieve your requirement:

Find the modified code example here:

<SfDropDownList TValue="TValue" TItem="TItem" @ref="@DDList"

                        Value="@ValueT"

                        ID="@ID"

                        ValueChanged="ValueTChanged"

                        ValueExpression="@ValueTExpression"

                        Placeholder="@Placeholder"

                        CssClass=@($"borderOnlyRight {CssClass}") OnChange="OnInput"

                        FloatLabelType="FloatLabelType.Auto"

                        ShowClearButton="@ShowClearButton"

                        Query="@Query"

                        AllowFiltering=@AllowFiltering

                        >

            <DataManager Adaptor="Adaptors.CustomAdaptor" AdaptorInstance="@typeof(TAdapter)" />

            <DropDownListFieldSettings Text="@PropTextItem" Value="@PropValueItem" />

            <DropDownListEvents TItem="TItem" TValue="TValue" Filtering="@Filtering"  OnActionComplete="@OnAutoComplete" OnClose="OnCloseEvent" OnValueSelect="OnSelect"></DropDownListEvents>

        </SfDropDownList>


Find the modified sample in the attachment:

Regards,

Sureshkumar P


Attachment: Solution1_3bf54f69.zip


KA kavit February 16, 2023 09:36 AM UTC

Thanks for the solution. How did you solve this...



SP Sureshkumar P Syncfusion Team February 17, 2023 10:42 AM UTC

Kavit, after the EditContext NotifyFieldChanged reupdate the component value so once reupdate the value property the index is the most priority to update the value. Which is the reason the component value reset to null.


Marked as answer

KA kavit February 17, 2023 11:31 AM UTC

thanks for the explanation


Loader.
Live Chat Icon For mobile
Up arrow icon