原創(chuàng)|行業(yè)資訊|編輯:龔雪|2020-01-19 10:21:21.770|閱讀 167 次
概述:本文主要介紹如何使用Kendo UI for jQuery數(shù)據(jù)管理中的網(wǎng)格排序功能,默認(rèn)情況下,禁用網(wǎng)格排序。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
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四個(gè)控件。Kendo UI for jQuery是創(chuàng)建現(xiàn)代Web應(yīng)用程序的最完整UI庫。
本文主要介紹如何使用Kendo UI for jQuery數(shù)據(jù)管理中的網(wǎng)格排序功能,默認(rèn)情況下,禁用網(wǎng)格排序。
<!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> <script src="../content/shared/js/orders.js"></script> <div id="example"> <div class="demo-section k-content wide"> <h4>Grid with single column sorting enabled</h4> <div id="singleSort"></div> </div> <div class="demo-section k-content wide"> <h4>Grid with multiple column sorting enabled</h4> <div id="multipleSort"></div> </div> <script> $(document).ready(function () { $("#singleSort").kendoGrid({ dataSource: { data: orders, pageSize: 6 }, sortable: { mode: "single", allowUnsort: false }, pageable: { buttonCount: 5 }, scrollable: false, columns: [ { field: "ShipCountry", title: "Ship Country", sortable: { initialDirection: "desc" }, width: 300 }, { field: "Freight", width: 300 }, { field: "OrderDate", title: "Order Date", format: "{0:dd/MM/yyyy}" } ] }); $("#multipleSort").kendoGrid({ dataSource: { data: orders, pageSize: 6 }, sortable: { mode: "multiple", allowUnsort: true, showIndexes: true }, pageable: { buttonCount: 5 }, scrollable: false, columns: [ { field: "ShipCountry", title: "Ship Country", width: 300 }, { field: "Freight", width: 300 }, { field: "OrderDate", title: "Order Date", format: "{0:d}" } ] }); }); </script> <style> .demo-section h3 { margin: 5px 0 15px 0; } </style> </div> </body> </html>
要啟用Grid的排序功能,請(qǐng)將sortable選項(xiàng)設(shè)置為true。 結(jié)果,將應(yīng)用默認(rèn)的單列排序功能。
為了增強(qiáng)Grid的性能,通過將數(shù)據(jù)源的serverSorting選項(xiàng)設(shè)置為true,在服務(wù)器上應(yīng)用排序操作。 啟用服務(wù)器排序后,您將收到默認(rèn)的orderBy參數(shù),該參數(shù)包含將應(yīng)用數(shù)據(jù)集排序列的字段名稱。
如圖:?jiǎn)⒂昧伺判蚬δ艿木W(wǎng)格
網(wǎng)格支持以下排序模式:
單列排序
默認(rèn)情況下,當(dāng)sortable設(shè)置為true時(shí),網(wǎng)格將應(yīng)用單列排序。 您還可以通過將可編輯的mode選項(xiàng)設(shè)置為single來配置單列排序模式。
$("#grid").kendoGrid({ sortable: true // Other configuration. });
多列排序
要啟用多列排序,請(qǐng)將模式選項(xiàng)可編輯設(shè)置為多個(gè)。
$("#grid").kendoGrid({ sortable: { mode: "multiple" }, // Other configuration. });
掃描關(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)