This is a migrated thread and some comments may be shown as answers.

Clearing a DropDown value

3 Answers 1300 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 05 Sep 2019, 04:23 PM
I've noticed what I think is a bug with the dropdown. If you bind a dropdown to a value (controlled in component state), you can have the value be undefined to start, and you get a dropdown with no selection. However, if you then manually select one of the entries, and programmatically set the value back to undefined, it does NOT clear the selection, even though the value (correctly) is undefined.

Is there some trick to this? For comparison, I used a vanilla textbox and the value does correctly clear, so I am pretty sure this is a Kendo issue.

3 Answers, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 06 Sep 2019, 02:43 PM

FWIW, I found an old post relating to the jQuery framework suggesting the the ComboBox be used for this case, as opposed to the DropDown (that is, that this is known/"expected" behavior for the DropDown). I tried changing the controls to ComboBoxes, and still see the same result (setting the bound value to unknown or null does not actually update the displayed value).

The only workaround we've found is to have a dummy "<None>" entry in the list and "clearing" it back to that value. This is probably "good enough", but it seems like the control should be able to handle it natively (it DOES behave as desired when the value is initially undefined, but does not if the value gets set BACK to undefined).

0
Accepted
Stefan
Telerik team
answered on 09 Sep 2019, 06:09 AM

Hello, Jason,

This can be done setting the value to null instead of undefined.

Please check the following forum post this an example:

https://www.telerik.com/forums/how-to-clear-selected-item-from-dropdown

Regards,
Stefan
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jason
Top achievements
Rank 1
answered on 09 Sep 2019, 12:50 PM
Thanks, Stefan! My coworker had said it didn't work with either undefined or null, and I only verified it myself with undefined. Not sure what he was doing that it didn't work with null, but I was able to see it work.
Tags
General Discussions
Asked by
Jason
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or