23 Best Kendo UI Angular 2 DropDownList Actions [How To]

Kendo ui Angular 2 Filters Dropdown List [How To]

“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                                          

Example as,

@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!!
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.