Completed
Last Updated: 31 May 2022 06:54 by ADMIN
Release 3.4.0
Chris
Created on: 04 Mar 2021 10:55
Category: ComboBox
Type: Bug Report
5
Multiple identical values for the TextField cause incorrect selection

In my data, I have multiple identical values for the TextField of the ComboBox. When the user selects one of them and focuses away from the component the selected value changes to the first instance of the items with the same TextFields, although they have different ValueFields.

Reproduction:

<TelerikComboBox Data="@myDdlData" 
                 TextField="MyTextField" 
                 ValueField="MyValueField" 
                 Value="selectedValue" 
                 ValueChanged="@((int? id) => ValueChangedHandler(id))" 
                 FilterOperator="StringFilterOperator.Contains"
                 Filterable="true">
</TelerikComboBox>

@code {
    private List<MyDdlModel> myDdlData { get; set; }

    private void ValueChangedHandler(int? id)
    {
        selectedValue = id;
    }

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

    int? selectedValue { get; set; }

    protected override void OnInitialized()
    {
        myDdlData = new List<MyDdlModel>()
        {
            new MyDdlModel()
            {
                MyValueField = 1,
                MyTextField = "John Smith"
            },
            new MyDdlModel()
            {
                MyValueField = 2,
                MyTextField = "John Smith"
            },
            new MyDdlModel()
            {
                MyValueField = 3,
                MyTextField = "John Smith"
            },
            new MyDdlModel()
            {
                MyValueField = 4,
                MyTextField = "Alice Jones"
            },
            new MyDdlModel()
            {
                MyValueField = 5,
                MyTextField = "Alice Jones"
            },
        };
    }
}

0 comments