SfDropDownList Not Selecting Item

Hello,

I am having issues getting the dropdownlist component to select an item. I can get the items in the data source to appear correctly, but clicking them does not add the value. Rather, "undefined" remains in the box.


My item class is as follows:

public class Project
{
public int Id {get;set;}
public string Name {get;set;}
public string Number {get;set;}
}

The component is here:

<SfDropDownList TItem="Project" TValue="int" DataSource="_projects"> //_projects is just a list of projects and is initialized and awaited during OnInitializedAsync()
<DropDownListFieldSettings Text="Name" Value="Id"></DropDownListFieldSettings>
</SfDropDownList>

Changing the int to int? removes the undefined issue, but still does not let me select any of the items on the list.

Please let me know if you need further information. I appreciate the assistance.

3 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team July 24, 2020 01:37 PM UTC

Hi Bronson, 


Greetings from Syncfusion support. 


We checked the reported requirement. We would like to inform you that, the reported issue is not occurred in the 18.2.46 version.  


For your reference, we have prepared the sample and attached it below. 

  
  
  
If you are still facing the problem, then could you please get back to us with those issue details (issue reproducing sample/if possible modify the below sample to replicate the issue/sufficient code to replicate the issue and Syncfusion package version) that will help us to check and proceed further at our end.  

Regards, 
Sevvandhi N 



IV Ivan August 26, 2020 05:35 AM UTC

The above problem has not been fixed, including in your example.
The string "undefined" in placeholder appears when binding to type int.
Expand the list, do not select anything, remove focus from the SfDropdownList and expand the list again.


SN Sevvandhi Nagulan Syncfusion Team August 27, 2020 01:55 PM UTC

Hi Bronson,    
  
Thanks for the update. 
    
This issue has arised as you have provided the TValue as int. We need to provide the TValue as int?. Because we can delete the value using clear button. At that time, the value becomes null. To handle that case, we have provided the TValue as nullable. To get rid of the reported issue, change the TValue as int?.  Kindly refer to the below code and modified sample,    
    
     <SfDropDownList TItem="GameFields" TValue="int?" DataSource="@Games"> 
        <DropDownListFieldSettings Text="Text" Value="ID"></DropDownListFieldSettings> 
    </SfDropDownList> 
    
    
Also provide the field’s value property type also nullable.   
   
public class GameFields 
    { 
        public int? ID { get; set; } 
        public string Text { get; set; } 
    } 
   
  
 
    
Regards,    
Sevvandhi N    


Marked as answer
Loader.
Up arrow icon