Autocomplete Filtering / updateData Not Working

Hi,

I have what seems like it should be a fairly simple use case, but it's just not working as it should.

Given a local data source (an array of objects) with a simple model like so:

public countries = [
     {"description": "Australia", "code": "AU"},
     {"description": "France", "code": "FR"}
]

I want to use autocomplete to be searchable by the description field, to display the description field, but to store the code field as the value.

Looking at all the examples in the documentation I've got this setup:

HTML:

<ejs-autocomplete 
  formControlName="country_form_control"
     [dataSource]='countries'
     [fields]='autocompleteFields'
     [itemTemplate]="autocompleteItemTemplate"
     (filtering)="onFiltering($event)">
</ejs-autocomplete>

Angular:

public autocompleteFields: Object = {value: 'code'}
public autocompleteItemTemplate:string= "${description}";
public onFiltering (e)
{
console.log("on filtering override");
e.preventDefaultAction = true;
var query = new Query().where("description","contains",e.text, true);
e.updateData(this.adminTools.fullPortsListForSearches, query);
}

When I try using the autocomplete to enter any text data I always get 'No Results Found', no matter what string I enter.

The value/text relationship works when I load existing data.  For example when the form control is set to a "code" value the autocomplete displays the "description" value:

this.country_form_control.setValue("AU");

The autocomplete correctly shows "Australia" as the value.

My console debug shows that the onFiltering() function is being called correctly.

How do I get the data in the autocomplete to correctly display based upon filtering the data source using the text the user types?


1 Reply 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team June 14, 2021 12:47 PM UTC

Hi James, 


Greetings from Syncfusion support. 



We checked your query. We prepared the sample based on the mentioned scenario and we were unable to replicate the issue at out end. The filtering works as expected for custom name fields. Please refer the below sample. 




We request you to compare the above sample with your application and reproduce the reported issue in the above sample. It would be helpful to investigate the issue further at our end. 


Note: We don’t have text property support for fields in the autocomplete component. If you used both text and value property, then filtering will not works as expected. Please refer the below KB documentation for more information. 




Regards, 
Sevvandhi N 



Marked as answer
Loader.
Up arrow icon