“How to filter dropdown list using kendo ui Angular 2”?
The “Kendo UI Angular 2 DropDownList” is a form component and used binds the data list and chooses a single predefined value as per you from a dropdown list.
Filters are concepts that work with separation of record based on column and these filters are used to display the array items are filtered by the help of user input filter key text and on every character input the component triggers a filterChange event and returns back to the filtered result.
To enable the filterable property, we need to set the filterable property is true and the detail show in below example,
Stayed Informed – Live demo Plunker
Stayed Informed – Best 69 Angular 2 Interview Questions and Answers
@Component({ selector: 'my-app', template: ` <kendo-dropdownlist [data]="data" [filterable]="true" [textField]="'text'" [valueField]="'value'" (filterChange)="ddlFilter($event)"></kendo-dropdownlist>` }) class AppComponent { public source: Array<{ text: string, value: number }> = [ { text: "Anil Singh", value: 1 }, { text: "Sunil", value: 2 }, { text: "Alok", value: 3 }, { text: "Dilip", value: 4 }, { text: "Raju", value: 5 }, { text: "Avalish", value: 6 }, { text: "Sanjay", value: 7 } ]; public data: Array<{ text: string, value: number }>; constructor() { this.data = this.source.slice(); } ddlFilter(value) { this.data = this.source.filter((txt) => txt.text.toLowerCase().indexOf(value.toLowerCase()) !== -1); } }
References,
I hope you
are enjoying with this post! Please share with you friends. Thank you!!