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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

itemData passed to change event contains incorrect row from dataSource

Thread ID:





147126 Sep 2,2019 01:33 PM UTC Sep 5,2019 03:51 AM UTC ASP.NET Core - EJ 2 4
Tags: AutoComplete
Asked On September 2, 2019 04:01 PM UTC

We have an autocomplete dropdown of zipcodes grouped by city names. There are some cases where 2 cities have the same zipcode:

When the user selects an entry like this, the data passed to the change event is wrong. Specifically, the "itemData" property of the argument contains always the first instance of the zipcode in the datasource, not the actually selected one, so the returned city name is wrong. The "item" property on the other hand contains the correct user selected row. Please see attached picture of firefox console log:

Narayanasamy Panneer Selvam [Syncfusion]
Replied On September 3, 2019 11:14 AM UTC

Hi András, 
Greetings from Syncfusion support. 
We have validated your query. The reported issue is occurred because of you have mapped fields property to AutoComplete that contains duplicate items to the value property. In AutoComplete the items must be unique. For your requirement we suggest you use ComboBox, instead of using AutoComplete. In ComboBox, we have text and value property. Also, it has the filtering support which is similar to AutoComplete. In the below example we have mapped Id to value API and Zipcode to text API. 
Code example: 
<ejs-combobox id="city" placeholder="Select a Zipcode" popupHeight="200px" dataSource="@ViewBag.data" change="onChange"> 
<e-combobox-fields groupBy="Category" value="Id" text="Zipcode"></e-combobox-fields> 
public class City 
public int Zipcode { get; set; } 
public string Category { get; set; } 
public string Id { get; set; } 
public List<City> CityList() 
List<City> city = new List<City>(); 
city.Add(new City { Zipcode = 7300, Category = "Mecsekpoloske", Id = "item1" }); 
city.Add(new City { Zipcode = 7300, Category = "Komlo", Id = "item2" }); 
return city; 
Please find the screenshot for your reference, 
For your convenience we have prepared a sample. Please get it from the below link, 

Narayanasamy P. 

Replied On September 3, 2019 11:19 AM UTC

Great, thank you very much for the clarification!

Replied On September 3, 2019 03:21 PM UTC

Unfortunately after checking the solution in depth and trying to implement it in various ways I've found out that it requires us to post the zipcode as an Id number, instead of the plain zipcode string. Our application uses zipcodes in many places, and this solution needs a lot of work to be done, and needs database modification. Since we only need the City name to update another field's value from javascript, at this point I'm considering simply parsing the html node for the city name.

Narayanasamy Panneer Selvam [Syncfusion]
Replied On September 5, 2019 03:51 AM UTC

Hi András,  
Thanks for the update. please let us know if you need any further assistance. 
Narayanasamy P. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon