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

Dropdownlist does not close after selection

2 Answers 1728 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Veteran
Iron
Andrew asked on 11 Feb 2021, 03:58 PM

The dropdownlist does not close after selecting a value from the list. It will close once it has lost focus.

I tested this is chrome and firefox and there no JavaScript errors in the thrown

 

 

<label class="ic-Label" for="RoomTypes">Room Type:</label>                         <TelerikDropDownList Id="RoomTypes" Width="230px" Data="@RoomTypes" TextField="Text" ValueField="Value" @bind-Value="_appData.RoomSearchData.RoomType"></TelerikDropDownList>

 

does anyone have an idea?

2 Answers, 1 is accepted

Sort by
2
Accepted
Eric R | Senior Technical Support Engineer
Telerik team
answered on 12 Feb 2021, 03:57 PM

Hi Andrew,

Thank you for providing the component markup. I suspect the behavior is because the selectedValue data type is of a different type than the ValueField object. Let me explain more with a sample below. 

Sample

In the following component, notice the selectedValue is a string data type and the MyValueField is an int. This is an invalid scenario that can cause similar issues.

This is one possible (invalid) implementation to cause the behavior where the dropdown only closes after it has lost focus even though the selection does change. 

<span>You Selected Value: @selectedValue</span>
<br />
<br />
<label for="Items">Items: </label>
<TelerikDropDownList Id="Items" Data="@myDdlData" TextField="MyTextField" ValueField="MyValueField" @bind-Value="selectedValue">
</TelerikDropDownList>

@code {
    public class MyDdlModel
    {
        public int MyValueField { get; set; }
        public string MyTextField { get; set; }
    }

    string selectedValue { get; set; }

    IEnumerable<MyDdlModel> myDdlData = Enumerable.Range(1, 20).Select(x => new MyDdlModel { MyTextField = $"item{x}", MyValueField = x });
}

Potential Fix

<span>You Selected Value: @selectedValue</span>
<br />
<br />
<label for="Items">Items: </label>
<TelerikDropDownList Id="Items" Data="@myDdlData" TextField="MyTextField" ValueField="MyValueField" @bind-Value="selectedValue">
</TelerikDropDownList>

@code {
    public class MyDdlModel
    {
        public int MyValueField { get; set; }
        public string MyTextField { get; set; }
    }

    int selectedValue { get; set; }

    IEnumerable<MyDdlModel> myDdlData = Enumerable.Range(1, 20).Select(x => new MyDdlModel { MyTextField = $"item{x}", MyValueField = x });
}

Wrapping Up

Understandably, the above implementation and potential fix may not apply to your scenario. If your implementaiton is different, I ask that you provide more information about your data model and data collection for the DropDownList.

In the meantime, please let me know if you need any additional information. Thank you.

Regards,


Eric R | Senior Technical Support Engineer
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 12 Feb 2021, 05:35 PM

Thanks that worked, but I do find it weird that is will still bind the selected value and work except that the ui does not update.

If there is an internal error then maybe there is away to display bring that forward to the developer or just ignore it.

 

Tags
DropDownList
Asked by
Andrew
Top achievements
Rank 1
Veteran
Iron
Answers by
Eric R | Senior Technical Support Engineer
Telerik team
Andrew
Top achievements
Rank 1
Veteran
Iron
Share this question
or