mehdihadeli
11/6/2018 - 1:52 PM

combobox filter

  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)))
                )
            )
        );
    }
     <kendo-combobox formControlName="serviceCategoryID" [data]="serviceCategoryData" [valuePrimitive]="true"  [suggest]="true" #cbServiceCategory
                    [textField]="'value'" [valueField]="'key'" class="form-control" id="drServiceLevel" >
      </kendo-combobox>