翻譯|使用教程|編輯:龔雪|2019-10-30 09:55:13.263|閱讀 306 次
概述:Kendo UI Filter小部件是一個(gè)統(tǒng)一的控件,用于篩選具有數(shù)據(jù)源的數(shù)據(jù)綁定組件。Kendo UI for jQuery R3 2019 SP1全新發(fā)布,立即下載體驗(yàn)新版哦!
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷售中 >>
相關(guān)鏈接:
Kendo UI目前最新提供Kendo UI for jQuery、Kendo UI for Angular、Kendo UI Support for React和Kendo UI Support for Vue四個(gè)控件。Kendo UI for jQuery是創(chuàng)建現(xiàn)代Web應(yīng)用程序的最完整UI庫(kù)。
小部件是一個(gè)統(tǒng)一的控件,用于篩選具有數(shù)據(jù)源的數(shù)據(jù)綁定組件。
Filter的用戶界面對(duì)于沒(méi)有內(nèi)置UI進(jìn)行篩選但需要提供篩選器選項(xiàng)的數(shù)據(jù)綁定組件很有用,例如ListView,Chart和Scheduler。 您可以添加或刪除用于過(guò)濾數(shù)據(jù)的字段,并為每個(gè)字段選擇過(guò)濾器的全局邏輯(AND或OR)和過(guò)濾器運(yùn)算符(例如,包含或等于)。您可以通過(guò)內(nèi)置按鈕或API調(diào)用應(yīng)用過(guò)濾,還可以選擇名稱,以這些名稱顯示給用戶并本地化過(guò)濾器操作符和消息。
要使用過(guò)濾器,請(qǐng)使用一個(gè)空的"div"元素,并在初始化腳本中提供其設(shè)置。
下面的示例演示如何:
注意:
<div id="filter"></div><ul id="listView"></ul> <script type="text/x-kendo-template" id="item"> <li> <strong>#= name #</strong>, aged #= age #, is on vacation: #= isOnLeave # </li> </script> <script> $(document).ready(function () { var dataSource = new kendo.data.DataSource({ data: [ { name: "Jane Doe", age: "25", isOnLeave: false }, { name: "John Doe", age: "33", isOnLeave: true }, { name: "John Smith", age: "37", isOnLeave: true }, { name: "Nathan Doe", age: 42, isOnLeave: false } ], schema: { model: { fields: { name: { type: "string" }, age: { type: "number" }, isOnLeave: { type: "boolean" } } } } }); $("#filter").kendoFilter({ dataSource: dataSource, expressionPreview: true, // Shows a text preview of the filter expression. applyButton: true, // Shows the built-in Apply button. fields: [ // Defining the fields is not mandatory. Otherwise, they will be taken from the data source schema. // If you define the fields, their names and types must match the data source definition. { name: "name", type: "string", label: "Name" }, { name: "age", type: "number", label: "Age" }, { name: "isOnLeave", type: "boolean", label: "On Vacation" } ], expression: { // Defining an initial filter expression is not required. logic: "and", filters: [ { field: "age", value: 30, operator: "gte" }, { field: "name", value: "Doe", operator: "contains" } ] } }).data("kendoFilter").applyFilter(); // Chain the method call to immediately apply filtering after the widget initialization because an initial filter is set. $("#listView").kendoListView({ dataSource: dataSource, template: kendo.template($("#item").html()) }); }); </script>
要引用現(xiàn)有的Filter實(shí)例,請(qǐng)使用jQuery.data()方法。 建立引用后,請(qǐng)使用Filter API來(lái)控制其操作。
var filter = $("#theFilter").data("kendoFilter");
掃描關(guān)注慧聚IT微信公眾號(hào),及時(shí)獲取最新動(dòng)態(tài)及最新資訊
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)