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?