private serviceCategoryDataSource: SelectItem<number, string>[];
public serviceCategoryData: SelectItem<number, string>[];
@ViewChild('cbServiceCategory')
cbServiceCategory: ComboBoxComponent;
this.opteamService.getAllServiceCategoriesLookup().subscribe(x => {
this.serviceCategoryDataSource = x;
this.serviceCategoryData = this.serviceCategoryDataSource.slice();
this.filterForCombobox(this.cbServiceCategory, this.serviceCategoryDataSource).subscribe(w => {
this.serviceCategoryData = w;
this.cbServiceCategory.loading = false;
});
});
//fiter combobox witha pharse
private filterForCombobox(cb: ComboBoxComponent, source: any): Observable<SelectItem<number, string>[]> {
return cb.filterChange.asObservable().pipe(
switchMap(phrase =>
from([source]).pipe(
tap(() => (cb.loading = true)),
delay(500),
map(item => item.filter(filterItem => this.lookupContainsItem(filterItem, phrase)))
)
)
);
}