Kendo AutoComplete achieves multiple filtering Conditions

Source: Internet
Author: User

Multiple filtering conditions are not supported when the Kendo AutoComplete is original.

$("#autocomplete").kendoAutoComplete({  filter: "contains"});
According to the API provided by AutoComplete, there are three filters available: startswith, endswith, Contains. But what should we do as a Chinese user. Most of the time, we hope that the searched items can be filtered by Chinese characters or pinyin, but the original AutoComplete cannot help us implement this function.

Next we will transform the autocomplete Based on AutoComplete to implement a multi-filter condition AutoComplete

The Code is as follows:

kendo.ui.plugin(kendo.ui.ComboBox.extend({    options: {        name: "MultiFilterComboBox"    },    _filterSource: function () {        this.dataSource.filter({            logic: "or",            filters: [                { field: "code", operator: "contains", value: this.text() },                { field: "name", operator: "contains", value: this.text() }            ]        });    }}));

Usage:

$ ("# Nation "). kendomultifiltercombobox ({placeholder: "Nationality... ", datatextfield:" name ", datavaluefield:" name ", filter:" contains ", datasource: [{Name: 'Han nationality, code: 'hanzu '}, <PRE name = "code" class = "JavaScript" style = "color: RGB (85, 85, 85); font-size: 14px; line-Height: 21px; "> name: 'miao nationality, code: 'miaozu '}
]});

 

HTML Tag:

<input id="Nation"/>

Now we have implemented the autocomplete of the combination filter conditions. The example only performs the or operation, and other operations are also possible. You can flexibly apply the operation and develop your own brain.






Kendo AutoComplete achieves multiple filtering Conditions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.