*
引用kendoUI-combobox組件,並過濾
定義組件裏需要用到的屬性:
allowCustom:是否允許用戶輸入不在數據集中的值,默認false
data:數據集
filterChange:定義過濾方法
filterable:是否過濾
valuePrimitive:是否原始類型數據
ngStyle:樣式
<kendo-combobox
[allowCustom]="false"
[data]="filterData"
(filterChange)="modelChanged.next($event)"
[(ngModel)]="value"
[filterable]="true"
[valuePrimitive]="true"
[ngStyle]="ngStyle"
></kendo-combobox>
public options: any[];
public ngStyle = {'width': '100%'};
public filterData = [];
modelChanged: Subject<object> = new Subject<object>();
handFilter(value) {
let datas = this.options;
this.filterData = [];
if (value)
datas = datas.filter(i => i.indexOf(value) != -1);
datas.forEach(i => {
this.filterData.push(i);
});
}
ngOnInit() {
this.Svc.query("基礎代碼#地區").then(data => {
this.options = [];
data.forEach(m => {
this.options.push(m["地區名稱"]);
})
this.filterData = this.options;
});
this.modelChanged.debounceTime(300).distinctUntilChanged().subscribe(m => this.handFilter(m));
}
sea.