翻譯|使用教程|編輯:龔雪|2020-01-10 09:38:30.140|閱讀 187 次
概述:Kendo UI for jQuery是創建現代Web應用程序的最完整UI庫。Kendo UI for jQuery數據管理中,網格的搜索面板和分頁功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Kendo UI for jQuery R3 2019 SP1試用版下載
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庫。
Kendo UI for jQuery數據管理中,網格的搜索面板和分頁功能。
網格小部件具有內置功能,使用戶可以搜索數據。 搜索面板在后臺使用過濾功能來僅顯示網格中的相關記錄。
入門指南
要啟用該功能,請在工具欄配置中包含搜索選項。另外,可以自定義搜索輸入中輸入值時要搜索的字段。
$("#grid").kendoGrid({ toolbar: ["search"], search: { fields: ["ContactTitle"] } ... });
已知局限性
在過濾器文本框中啟用過濾后,所有Grid列的數據將使用在搜索文本框中輸入的值填充。
默認情況下,禁用網格中的分頁。
入門指南
要啟用網格的分頁功能,請將其pageable選項設置為true。
為了使分頁正常工作:
$("#grid").kendoGrid({ pageable: true // Other configuration. });
在服務器上分頁
為了增強Grid的性能,通過將數據源的serverPaging選項設置為true,在服務器上應用分頁操作。 啟用serverPaging時,數據源將以下默認參數發送到服務器:
例如,要顯示60條記錄的數據集中的第3頁(每頁分為10條記錄),網格將發送skip: 20, top: 10。
Grid與發送和接收JSON有效負載的HTTP請求一起使用。 例如,要將窗口小部件綁定到特定數據子集的特定頁面,請指示dataSource使用serverPaging。 結果,它將直接使用接收到的數據。 相同的規則適用于過濾、分組、聚合和排序操作。
$(document).ready(function(){ $("#grid").kendoGrid({ groupable: true, scrollable: true, sortable: true, pageable: true }); });
配置Pager
默認情況下,即使網格的數據源項總數小于pageSize值,它也會顯示一個pager。
從Kendo UI 2017 R3版本開始,網格使您可以通過pageable.alwaysVisible配置屬性來切換pager的可見性,如果pageable.alwaysVisible值為false,則pager將獲得以下操作:
<!DOCTYPE html> <html> <head> <title></title> <link rel="stylesheet" href="styles/kendo.common.min.css" /> <link rel="stylesheet" href="styles/kendo.default.min.css" /> <link rel="stylesheet" href="styles/kendo.default.mobile.min.css" /> <script src="js/jquery.min.js"></script> <script src="js/kendo.all.min.js"></script> </head> <body> <div id="example"> <div id="grid"></div> <div class="box wide"> <h4>Configure</h4> <label for="btnPagerVisibility">alwaysVisible:</label> <input type="checkbox" id="btnPagerVisibility" /> </div> <script> $(document).ready(function () { var crudServiceBaseUrl = "http://demos.telerik.com/kendo-ui/service", dataSource = new kendo.data.DataSource({ transport: { read: { url: crudServiceBaseUrl + "/Products", dataType: "jsonp" }, update: { url: crudServiceBaseUrl + "/Products/Update", dataType: "jsonp" }, destroy: { url: crudServiceBaseUrl + "/Products/Destroy", dataType: "jsonp" }, create: { url: crudServiceBaseUrl + "/Products/Create", dataType: "jsonp" }, parameterMap: function(options, operation) { if (operation !== "read" && options.models) { return {models: kendo.stringify(options.models)}; } } }, batch: true, pageSize: 10, schema: { model: { id: "ProductID", fields: { ProductID: { editable: false, nullable: true }, ProductName: { validation: { required: true } }, UnitPrice: { type: "number", validation: { required: true, min: 1} }, Discontinued: { type: "boolean" }, UnitsInStock: { type: "number", validation: { min: 0, required: true } } } } } }); $("#grid").kendoGrid({ dataSource: dataSource, navigatable: true, height: 400, filterable: true, pageable: { alwaysVisible: false, pageSizes: [5, 10, 20, 100] }, toolbar: ["create", "save", "cancel"], columns: [ "ProductName", { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: 120 }, { field: "UnitsInStock", title: "Units In Stock", width: 120 }, { field: "Discontinued", width: 120, editor: customBoolEditor }, { command: "destroy", title: " ", width: 150 }], editable: true }); var grid = $("#grid").data("kendoGrid"); $("#btnPagerVisibility").change(function() { grid.setOptions({ pageable: { alwaysVisible: this.checked } }); }); }); function customBoolEditor(container, options) { $('<input class="k-checkbox" type="checkbox" name="Discontinued" data-type="boolean" data-bind="checked:Discontinued">').appendTo(container); $('<label class="k-checkbox-label">​</label>').appendTo(container); } </script> </div> </body> </html>
掃描關注慧聚IT微信公眾號,及時獲取最新動態及最新資訊
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網