我使用 Telerik kendo ui 网格。
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "POST",
prefix: "",
dataType: "json",
serverFiltering: true,
EnableCustomBinding:true,
transport: {
read: "http://localhost:51618/Home/Customers_Read"
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
contentType: "application/json; charset=utf-8"
},
height: 550,
groupable: true,
filterable:true,
sortable: true,
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5
},
columns: [{
template: "<div class='customer-photo'" +
"style='background-image: url(../content/web/Customers/#:data.CustomerID#.jpg);'></div>" +
"<div class='customer-name'>#: ContactName #</div>",
field: "ContactName",
title: "Contact Name",
width: 240
}, {
field: "ContactTitle",
title: "Contact Title"
}, {
field: "CompanyName",
title: "Company Name"
}, {
field: "Country",
width: 150
}]
});
});
</script>
我的控制器是:
public ActionResult Customers_Read([DataSourceRequest] DataSourceRequest request)
{
// do something
}
请求发送表格网格是:
http://localhost:51618/Home/Customers_Read?take=20&skip=0&page=1&pageSize=20&sort%5B0%5D%5Bfield%5D=ContactName&sort%5B0%5D%5Bdir%5D=asc
但 datarequest 排序字段始终为空。