kendo AutoComplete實現多篩選條件,kendoautocomplete

來源:互聯網
上載者:User

kendo AutoComplete實現多篩選條件,kendoautocomplete

kendo autoComplete 原始情況下是不支援多篩選條件的

$("#autocomplete").kendoAutoComplete({  filter: "contains"});
根據autocomplete 提供的api可以知道使用filter有三種,分別是startswith, endswith , contains。但是作為中文使用使用者,我們該怎麼辦呢。很多時候,我們希望搜尋出來的東西可以通過漢字或者拼音過濾,但是原始的autocomplete是無法協助我們實現這以功能的。

接下來我們改造下,基於autocomplete做一個多過濾條件的autocomplete

具體代碼如下:

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() }            ]        });    }}));

使用方法:

$("#Nation").kendoMultiFilterComboBox({    placeholder: "民族...",    dataTextField: "name",    dataValueField: "name",    filter: "contains",    dataSource:[{name:'漢族',code:'hanzu'},<pre name="code" class="javascript" style="color: rgb(85, 85, 85); font-size: 14px; line-height: 21px;">name:'苗族',code:'miaozu'}
]});



html標籤:

<input id="Nation"/>

現在我們就實現過組合過濾條件的autocomplete,樣本只是做了或運算,其他的運算也是可以的,大家可以靈活應用,開發自己的大腦。







jquery autocomplete怎實現自動實現更新搜尋提示

很久以前做過,記不太清怎麼實現的了,好像是給對應的文字框價格keydown事件,然後無重新整理的擷取新資料
 
對於怎實現一個自訂介面的AutoCompleteTextView

AutoCompleteTextView有個長度的設定 多少長度彈出那個列表的,你設定一下就行了 具體的看看API
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.