原創|使用教程|編輯:龔雪|2019-11-05 09:35:19.187|閱讀 263 次
概述:Kendo UI Filter小部件是一個統一的控件,用于篩選具有數據源的數據綁定組件,本文主要介紹Kendo UI Filter中的過濾器設置運算符,歡迎下載Kendo UI R3 2019 SP1立即體驗!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Kendo UI目前最新提供Kendo UI for jQuery、Kendo UI for Angular、Kendo UI Support for React和Kendo UI Support for Vue四個控件。Kendo UI for jQuery是創建現代Web應用程序的最完整UI庫。
小部件是一個統一的控件,用于篩選具有數據源的數據綁定組件。
Filter提供用于定義將在過濾下拉列表中顯示哪些過濾器運算符的選項。operators字段采用帶有每種字段類型可用操作符的文字,您可以列出所需的操作符及其文本。
下面的示例演示如何設置等于和包含字符串字段的過濾器運算符,以及如何將數字字段的大于和小于過濾器運算符設置為字符串字段。
<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, operators: { string: { eq: kendo.ui.Filter.fn.options.operators.string.eq, // Take the default Kendo UI text. contains: "Partially Matches" // Define a custom text. }, number: { gte: "Larger Than", // Define a custom text. lt: kendo.ui.Filter.fn.options.operators.number.lt // Take the default Kendo UI text. } }, 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>
掃描關注慧聚IT微信公眾號,及時獲取最新動態及最新資訊
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網