<ejs-autocomplete id='atcelement' name="name_stage" #remote [dataSource]='data | async' [(ngModel)]="testStage.spielbezeichnung" inputFieldWhiteSpaceValidator
[(value)]="testStage.spielbezeichnung" (select)="selectedSpiel($event)" required [locale]="locale" [autofill]='autofill' [placeholder]="spielInputPlaceholder"
[fields]='fields' (filtering)="onFiltering($event, remote)" (keydown.Tab)="validationTest();" [highlight]='highlight'>
<ng-template #itemTemplate="" let-data="">
<!--set the value to itemTemplate property-->
<span><span class='name'> {{data.spielbezeichnung}}</span><span class ='city'> von {{data.betriebsname}}</span></span>
</ng-template>
</ejs-autocomplete>
public fields: Object = { value: 'spielbezeichnung' };
public data: Observable<any>;
public autofill: Boolean = true;
public highlight: Boolean = true;
public locale: string = 'de';located in different folder:
loadCldr(
require('./../calendar/de/numbers.json'),
require('./../calendar/de/ca-gregorian.json'),
require('./../calendar/de/numberingSystems.json'),
require('./../calendar/de/timeZoneNames.json'),
require('./../calendar/de/weekData.json')
);calling this function on ngoninit:syncfusionLocalization() {
L10n.load({
de: {
dropdowns: {
noRecordsTemplate: 'Keine Einträge gefunden',
actionFailureTemplate: 'actionFailureTemplate',
},
},
});
}public getData(remote: AutoCompleteComponent, text: string): Observable<any> {
let params = new HttpParams().set('spielbezeichnung.contains', text);
return this.http.get('services/bettab/api/V1/betriebe/Spielstaetten/all', { params: params }).pipe(
map(data => {
remote.hidePopup();
setTimeout(() => remote.showPopup(), 500);
// return ((<any>data).value);
return data;
})
);
}
public onFiltering: EmitType<FilteringEventArgs> = (e: FilteringEventArgs, remote: AutoCompleteComponent) => {
if (e.text.length >= 2) {
this.data = this.getData(remote, e.text);
e.preventDefaultAction = true;
} else {
e.cancel = true;
}
this.validationTest();
};
|
<ejs-autocomplete id='games' #sample [dataSource]='data | async' [fields]='fields' [locale]='locale'
autofill ="true" minLength="2" (filtering)="onFiltering($event)" ></ejs-autocomplete |
|
ngOnInit(): void {
this.syncfusionLocalization();
}
syncfusionLocalization() {
L10n.load({
de: {
dropdowns: {
noRecordsTemplate: 'Keine Einträge gefunden',
actionFailureTemplate: 'actionFailureTemplate',
},
},
});
}
public onFiltering(args: any): void {
args.preventDefaultAction = true;
let query: Query = new Query();
query = (args.text !== '') ? query.where('Game', 'startswith', args.text, true) : query;
let data = this.dataService.fetch(args.text).subscribe(result => {
args.updateData(result,query);
});
} |